-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi, I'm trying to implement writing to an NFC tag using neard via the D-Bus interface.
The logic that I have currently is the following:
- Start polling in the "Initiator" mode: org.neard.Adapter.StartPollLoop("Initiator")
- Wait for the tag to be detected. I'm using the general org.freedesktop.DBus.ObjectManager.InterfaceAdded signal for that.
- Call "Write" on the new Tag: org.neard.Tag.Write(NdefMessageData)
The problem is that if I try to write immediately after the tag detection, I get the following errors:
method call time=1741789907.644197 sender=:1.202 -> destination=org.neard serial=14 path=/org/neard/nfc0/tag39; interface=org.neard.Tag; member=Write
array [
dict entry(
string "Encoding"
variant string "UTF-8"
)
dict entry(
string "Language"
variant string ""
)
dict entry(
string "Representation"
variant string "Some Text"
)
dict entry(
string "Type"
variant string "Text"
)
]
error time=1741789907.644494 sender=:1.194 -> destination=:1.202 error_name=org.neard.Error.InvalidArguments reply_serial=14
string "Invalid arguments"
error time=1741789907.644518 sender=:1.194 -> destination=:1.202 error_name=org.neard.Error.Failed reply_serial=14
string "No space left on device"
At the same time the neard console output shows:
neard[8783]: Not enough space on tag 17 0
So, somehow it thinks that the tag has 0 bytes available.
If I delay the write a bit (say, for 100ms), the write succeeds, but neard crashes with a segmentation fault afterwards. I should probably create a separate bugreport for that.
I only managed to get a successful write without a crash if I do it after I got the notification about the "org.neard.Record".
So, basically, I had to wait until the read from the tag is completed, and only then write something to it.
However, I cannot use this logic reliably, because in general case there can be more that one record on the tag. Or, there can be no records at all...
So, what is the correct way to write an NDEF message to an NFC tag?