Skip to content

latinosamuel/STM24LRNfcLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ST M24LR Nfc Library


HAR Logo

API JITPACK Language

πŸ“– Table of Contents

Table of Contents
  1. ➀ About The Library
  2. ➀ Features
  3. ➀ Integration
  4. ➀ Sample
  5. ➀ Release Note
  6. ➀ License

-----------------------------------------------------

πŸ“ About The Library

This library has as objective to help you write and read Non-NDEF NFC Tags, more specifically NFCv tags.
While, according to the official Android reference, it is the standard NDEF Tags you can read NdefMessage objects from extra intent and write to an NDEF tag by calling the writeNdefMessage method on the Tag object, it is not that simple when it comes to Non-NDEF NFC Tags: you will need to cope with raw commands and their payloads.
In the tests performed with the library, the M24LR16E-R chip from the STMicroelectronics brand was used.
The M24LR16E-R is organized as 2048 Γ— 8 bits in the I2C mode and as 512 Γ— 32 bits in the ISO 15693 and ISO 18000-3 mode 1 RF mode, 16 sectors of 16 sectors of 32 blocks of 32 bits.

-----------------------------------------------------

🎯 Features

This library has the following features:

➀ Process.READ_SINGLE_BLOCK - Allows you to read a single block of data from the nfcv tag
➀ Process.WRITE_SINGLE_BLOCK - Allows you to write a single block of data from the nfcv tag
➀ Process.READ_MULTIPLE_BLOCK - Allows you to read one or more blocks of data from the nfcv tag
➀ Process.WRITE_MULTIPLE_BLOCK - Allows you to write one or more blocks of data from the nfcv tag

-----------------------------------------------------

πŸ”¨ Integration

Below is a brief guide to using dependency management tools like maven or gradle.

Maven

Add the JitPack repository to your build file:

<repositories>
  <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
  </repository>
</repositories>

To use maven add this dependency to your pom.xml:

<dependency>
    <groupId>com.github.latinosamuel</groupId>
    <artifactId>STM24LRNfcLibrary</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Then you can just add the latest version to your build.

implementation 'com.github.latinosamuel:STM24LRNfcLibrary:1.0.0'

If you do not use any dependency management tool, you can find the latest standalone aar here.

-----------------------------------------------------

πŸ” Sample

Read Single Block:

  // Block number to read
  val blockNumber = 0
  M24LRInit().init(this@MainActivity, Process.READ_SINGLE_BLOCK, blockNumber)
      .completedListener(object : CompletedListener {
          override fun onProcessCompletedReadSingleBlock(blockNumber: Int, hexData: String) {
			        ...
          }
      }).errorListener(object : ErrorListener {
          override fun onProcessTerminated(terminationReason: TerminationReason, reason: String) {
              ...
          }

          override fun onProcessInterrupted(interruptReason: InterruptReason) {
              ...
          }
      }).iTagListener(object : ITagListener {
          override fun onTagFound() {
              ...
          }
      }).build(this@MainActivity)

Write Single Block:

  //Block number to write
  val blockNumber = 0
  //Data to write in the respective block in hexadecimal
  val data = "01506201"

  M24LRInit().init(this@MainActivity, Process.WRITE_SINGLE_BLOCK, blockNumber, data)
      .completedListener(object : CompletedListener{
          override fun onProcessCompletedWriteSingleBlock() {
              ...
          }
      }).errorListener(object :  ErrorListener{
          override fun onProcessTerminated(terminationReason: TerminationReason, reason: String) {
              ...
          }
          override fun onProcessInterrupted(interruptReason: InterruptReason) {
              ...
          }
      }).iTagListener(object : ITagListener{
          override fun onTagFound() {
              ...
          }
      }).build(this@MainActivity)

Read Multiple Blocks:

  //List with the number of blocks you want to read
  val blockNumberList = arrayListOf(0,1,2,3,4)
            
  M24LRInit().init(this@MainActivity, Process.READ_MULTIPLE_BLOCK, blockNumberList)
      .completedListener(object : CompletedListener{
          override fun onProcessCompletedReadMultipleBlock(response: HashMap<Int, String>) {
              ...
          }
      }).errorListener(object : ErrorListener{
          override fun onProcessTerminated(terminationReason: TerminationReason, reason: String) {
              ...
          }
          override fun onProcessInterrupted(interruptReason: InterruptReason) {
              ...
          }
      }).iTagListener(object : ITagListener{
          override fun onTagFound() {
              ...
          }
      }).build(this@MainActivity)

Write Multiple Blocks:

  //Hashmap example with block number and date in hex
  val map = HashMap<Int,String>()
  map[0]= "01506201"
  map[1]= "FFFFFFFF"
  map[2]= "FFF0FFFF"
  map[3]= "FFFFFFFF"
  map[4]= "FFF00003"

  M24LRInit().init(this@MainActivity, Process.WRITE_MULTIPLE_BLOCK, map)
      .completedListener(object : CompletedListener{
          override fun onProcessCompletedWriteMultipleBlock() {
              ...
          }
      }).errorListener(object :  ErrorListener{
          override fun onProcessTerminated(terminationReason: TerminationReason, reason: String) {
              ...
          }
          override fun onProcessInterrupted(interruptReason: InterruptReason) {
              ...
          }
      }).iTagListener(object : ITagListener{
          override fun onTagFound() {
              ...
          }
      }).build(this@MainActivity)

To see the full sample click here.

-----------------------------------------------------

πŸ““ Release Note

See release notes on github releases.

-----------------------------------------------------

πŸ”— License

Copyright 2021 Samuel Latino

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Library that allows writing and reading memory blocks from ST M24LR chips using NFCv

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages