Re: common NFC API draft / base for discussion

Hi Don,

On Tue, Apr 16, 2013 at 11:49:17AM -0400, Don Coleman wrote:
> Sam,
> 
> I also want a high level complete API, but I don't think we should hide the
> attributes of the NDEFRecord. The user should have access the tnf, type, id
> and raw payload of any record.  These should probably be immutable.
I think I'm starting to get your point here: Exporting such attributes would
be useful when we are dealing with non standard NDEFs. In such cases, if we
want the API caller to focus on the payload knowledge only, it will need to
know the record tnf and type before deciding if it's worth getting the payload
and parsing it.
By not exporting those attributes we assume the caller does have some NFC spec
knowledge and is capable of decoding an NDEF REcord header on his own. I agree
that's a discouraging assumption...
So I'm fine with exporting the tnf, type and payload (getPayload() ?). All
attibutes should be immutable, as you pointed out.


> Ideally most users will use NDEFRecordText, NDEFRecordURI, NDEFRecordMIME.
> There will be cases where some users want to construct non-standard
> NDEFRecords.  I propose that using attributes is clearer than using bytes,
> since with attributes the user does not need to know anything about
> NDEFMessage and NDEFRecord encoding.
I fully agree with that, and I second your proposal for a tnf + record payload
based NDEFRecord constructor. It makes a lot of sense to me and allows apps to
focus on actual payload and not NFC specific details (like an NDEF record
header).


> To clarify my point about Android, Android does deal with NDEF, but it also
> allows reading and writing bytes with tags like BlackBerry and Windows
> Phone. I was attempting to illustrate that getBytes() and setBytes() belong
> in NDEFMessage not NDEFRecord.
Yes, I agree getBytes make much more sense from NDEFMessage. We want
getPayload() from NDEFRecord.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

Received on Wednesday, 17 April 2013 10:08:50 UTC