Format Tag

Asked by Rafael on 2016-09-19

Hello! How to format a tag? I use the Format() function to clear, but when using the dump(), shows an empty tag.

This is my program:

import nfc

def connected(tag):
    clean = tag.format()
    if clean:
        print ("Clean correct")
    else:
        print ("clean incorrect")

clf = nfc.ContactlessFrontend("usb")
clf.connect(rdwr={"on-connect": connected})
clf.close()

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Tiedemann
Solved:
2016-09-21
Last query:
2016-09-21
Last reply:
2016-09-21

It is generally the idea of formatting to afterwards have an empty NDEF
capable tag. If all goes well then a freshly formatted Tag should have
Tag.ndef.message read as nfc.ndef.Message() without content.

On Mon, Sep 19, 2016 at 11:37 AM Rafael <
<email address hidden>> wrote:

> New question #399339 on nfcpy:
> https://answers.launchpad.net/nfcpy/+question/399339
>
> Hello! How to format a tag? I use the Format() function to clear, but when
> using the dump(), shows an empty tag.
>
> This is my program:
>
> import nfc
>
> def connected(tag):
> clean = tag.format()
> if clean:
> print ("Clean correct")
> else:
> print ("clean incorrect")
>
> clf = nfc.ContactlessFrontend("usb")
> clf.connect(rdwr={"on-connect": connected})
> clf.close()
>
> --
> You received this question notification because you are an answer
> contact for nfcpy.
>

Rafael (hibara94) said : #2

Sorry, I explain evil. I meant that when format () A tag, not shown empty with the function dump ()

By default the Tag.format() method only writes fresh NDEF management information to make the tag appear empty when reading NDEF. You will still see most of the old content in the memory view produced by Tag.dump(). To overwrite that old information use Tag.format(wipe=0) or some other 8-bit value for wipe.

Rafael (hibara94) said : #4

Thanks Stephen Tiedemann, that solved my question.