grundid/nfctools — pull request #12 by skjolber (2012-07-12 10:36:59+00:00)
Title: More error messages and hardening of low-level NdefRecord parsing

Added some more detailed error messages in one of the Handover Records. Rewrote some of the low-level ndef record decoding - basically the current approach should be hardened by checking for EOF and avoid using InputStream.available() altogether. Also there is no real distinction between

1. read ndef messages untill end of buffer
2. read ndef messages, start flag first and till end flag

Now, the spec seems a little shaky on this, the GenericControlRecord spec examples seems to require end and start flags individually on all subrecords, whereas in other cases, the approach is read start flag record first, red n records, and then stop at reading end flag record.

While I am pretty sure everything is supposed to be streaming-friendly (why make something like chunked records if this is not the idea), I guess the spec is unclear and in those cases we'd like to do #1 (other might conclude that #2 is #1), in all the other cases we'd like to do #2.

So I have made the above distinction with the added improvement of solid InputStream support.

#1: decode(...)
#2: decodeFully(...)

The improved coded spotted an error in a test case, where reading a payload array silently was cut short because EOF.