Closed Bug 960473 Opened 10 years ago Closed 10 years ago

[Gaia] NFC: readNDEF failed

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
1.4 S1 (14feb)

People

(Reporter: allstars.chh, Assigned: psiddh)

References

Details

(Whiteboard: [FT:RIL])

Attachments

(1 file)

I found NFCTag.readNDEF() is never working, 

http://dxr.mozilla.org/mozilla-central/source/dom/system/gonk/NfcContentHelper.js?from=NfcContentHelper.js#377

the line 
new requester.MozNdefRecord(record.tnf, record.type, record.id, record.payload); 
is returning {}

dump the object it's printing
[object XrayWrapper [object MozNdefRecord]]
blocking-b2g: --- → 1.3?
Whiteboard: [FT:RIL]
Please provide user impact of the bug not being fixed in 1.3
Flags: needinfo?(allstars.chh)
readNDEF is the basic interface used to read data from a Nfc Tag.
However, I am not sure if NFC will be included in v1.3.
Flags: needinfo?(allstars.chh)
Moving this to 1.4 as all the work in NFC will be in 1.4
blocking-b2g: 1.3? → 1.4?
readNDEF is important for tags that have more than one NDEF message is on the tag (there was a recent change Yoshi added to only send one up). Single messages are passed up automatically as part of the activity.
(In reply to Yoshi Huang[:allstars.chh] (Happy Chinese New Year 1.30 ~ 2.5) from comment #0) 
> dump the object it's printing
> [object XrayWrapper [object MozNdefRecord]]
Can you still access object's properties even in the frame script?
There is a mismatch between what gecko is sending and was used for applications. Given do want to remove extra copies and levels of indirection to get to the data, there's a fix application side. I've updated the WebNFC Wiki in the mean time, and can re-update if there's more discussion.

Solution:
For the DOM request, instead of:

  var recs = aDOMRequest.result.records;

apps should just use 

  var recs = aDOMRequest.result;

nfc_manager.js will need to be updated. However, it only routes messages, so it doesn't currently have any real need to use readNDEF at all, as it's far faster to just use the first message it already likely has (thus, readNDEF is generally never called).

To keep the original Wiki description with the extra records indirection, we'd need to create all objects in the application js compartment/window from chrome (which I just checked works), and return that. Not doing so will end up with the empty return: [{}].

A side issue is MozNdefRecord never had stringify implemented (it's in C++ currently due to this: Bug 929609).
(In reply to Garner Lee from comment #6)
> 
>   var recs = aDOMRequest.result.records;
> 
> apps should just use 
> 
>   var recs = aDOMRequest.result;
> 

yeah, it should be a Gaia bug.
Blocks: NFC-Gaia
No longer blocks: b2g-nfc
Summary: B2G NFC: readNDEF failed → [Gaia] NFC: readNDEF failed
Garner, would you like to take this bug?
Flags: needinfo?(dgarnerlee)
Assignee: nobody → psiddh
Will upload patch for this bug
Flags: needinfo?(dgarnerlee)
Attachment #8371907 - Flags: review?(alive)
Attachment #8371907 - Flags: review?(alive) → review+
Keywords: checkin-needed
Master: 8965405b0c73df406df5db2b72669f05ff5d90d6
Status: NEW → RESOLVED
Closed: 10 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 1.4 S1 (14feb)
blocking-b2g: 1.4? → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: