<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; Near Field Communication</title>
	<atom:link href="http://devblog.blackberry.com/tag/near-field-communication/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Tue, 18 Jun 2013 16:50:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; Near Field Communication</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Integrating NFC into your BlackBerry 10 Application</title>
		<link>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/</link>
		<comments>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/#comments</comments>
		<pubDate>Thu, 25 Oct 2012 15:34:13 +0000</pubDate>
		<dc:creator>mdwrim</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Near Field Communication]]></category>
		<category><![CDATA[nfc]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[use case]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=11782</guid>
		<description><![CDATA[Guest post from John Murray &#8211; Ed. You know, working in the Developer Relations team at Research In Motion® (RIM®), you get to get to play around with some fun stuff. Recently, Near Field Communication (NFC) has been exercising my brain cells. Some of you may be familiar with the NFC-related articles and code samples [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11782&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><i>Guest post from John Murray &#8211; Ed.</i></p>
<p>You know, working in the Developer Relations team at Research In Motion® (RIM®), you get to get to play around with some fun stuff. Recently, Near Field Communication (NFC) has been exercising my brain cells. Some of you may be familiar with the NFC-related articles and code samples that I’ve co-authored with my co-conspirator, Martin Woolley (<a href="http://twitter.com/mdwrim" target="_new">@mdwrim</a>), which you can find listed in our <a href="http://supportforums.blackberry.com/t5/Java-Development/NFC-Article-and-Code-Index/ta-p/1538775" target="_new">NFC Article and Code index</a>.</p>
<p>Now, whenever you mention NFC in a conversation, people invariably think of payments. Using NFC to make secure payments is perhaps the most obvious use case. However, when I think of NFC I tend to think of workflows as well. “Workflows,” you say? What do you mean?</p>
<p>OK, let’s think about it anecdotally. How many times have you had the challenge of transcribing some data from an external source to your handset whilst holding a bag and trying to hold a conversation at the same time? How many times have you tried to share information on your handset with someone else and had to struggle with inputting email addresses whilst doing three other things at the same time? These use cases are examples of Workflows, or Business Processes, that stumble on the point of having to accommodate more “human” interaction than is really necessary. NFC can be used to help streamline simple workflows that involve human interactions on mobile devices and ultimately help achieve efficiencies.</p>
<p><span id="more-11782"></span></p>
<p>So, having thought about this and how to demonstrate a simple but realistic use case (whilst also having some fun), we came up with the concept of the “Fun Run”.</p>
<p>Suppose you’re taking part in a charity “Fun Run” – not quite a marathon but something shorter for fun. The race organizers have developed a simple mobile application to allow you to register for the event and have placed NFC Tags in the starting and finishing areas. As you start you tap on one of the tags, your race timer is started as well as notifying the organizers that you have begun. When you pass the finish line, simply tap on one of the tags in the Finish area to stop your timer and notify the organizers of your finishing time!</p>
<p>In between the start and finish, there may be Way Points with NFC Reader devices that can be used to register intermediate times as the runner passes these points. Tap the handset to the NFC Reader and receive confirmation that the timing data has been transferred successfully.</p>
<p>OK, maybe it’s not 100% realistic, but as an example it is sufficient to demonstrate how a workflow process that involves having to record start and finish times and tracking progress can be made more efficient using NFC. The key learning point is to understand how integrating NFC technology into your application can be used to achieve efficiencies in similar processes.</p>
<h3><strong>The Applications</strong></h3>
<p>Let’s take a look at how we implemented this simple example using BlackBerry® 10 and BlackBerry® 7 NFC capable devices. There are really three use cases:</p>
<p>1. Tap your handset against an NFC tag at the start of the race to start your race timer.<br />
2. Tap your handset against NFC readers at intermediate waypoints during the race to transfer your current race timer data to an application that manages the reader.<br />
3. Tap your handset against an NFC tag at the end of the race to stop your race timer.</p>
<h3><strong>Acting on External Tag Events</strong></h3>
<p>To implement the first and last use case, we decided to provide two NFC tags that had specific NDEF messages as their content. There would be one tag that would start the timer at the start of the race and one tag that would stop the timer at the end of the race.</p>
<p>Specifically the data in the two tags is:</p>
<p><strong>1. Tag used to start the timer:</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;start&#8221;</p>
<p><strong>2. Tag used to stop the timer:</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;stop&#8221;</p>
<p>Why use this data? Well, firstly we choose an NDEF TNF (Type Name Format) for the NDEF Message because it allows us to define custom tag content that won’t clash with standard tag message types such as Smart Poster (“Sp”) or URL (“U”) or Text (“T”). We want to make sure that when one of these tags is presented, our application, and our application alone, is launched to process the tag.</p>
<p>Secondly, we choose a “Type” of &#8220;<strong>my.rim.com:myrecordtype</strong>&#8220;. Within the context of an External TNF record the Type can be arbitrary, but in order to prevent clashes with other organizations’ custom tag formats, we use the DNS naming scheme to set the namespace of the tag as “<strong>my.rim.com</strong>” to establish it as a RIM NDEF message. We further qualify it with a specific sub-type of “<strong>myrecordtype</strong>” since an organization may define a whole family of custom tag formats for its own use.</p>
<p>So, these settings ensure that these tags will only make sense to our application and not overlap with tags form elsewhere. The “Payload” of the two tags differs in that one has the string “<strong>start</strong>” and the other has the string “<strong>stop</strong>” to mark them as ones to be used to start and stop the timers respectively.</p>
<p>In the case of BlackBerry 10, our application registered with the Invocation Framework through the stanza in its “<strong>bar-descriptor.xml</strong>” file as shown in Figure 1. The “<strong>uris</strong>” attribute of the “<strong>&lt;property &#8230; /&gt;</strong>” tag has been set to the value “<strong>ndef://4/my.rim.com/myrecordtype</strong>” which a URI format specification of the two tags just described above.</p>
<pre>...
&lt;invoke-target id="com.example.NfcRaceTimeWay"&gt;
    &lt;type&gt;APPLICATION&lt;/type&gt;
    &lt;filter&gt;
        &lt;action&gt;bb.action.OPEN&lt;/action&gt;
        &lt;mime-type&gt;application/vnd.rim.nfc.ndef&lt;/mime-type&gt;
        &lt;property var="uris" value="ndef://4/my.rim.com/myrecordtype"/&gt;
    &lt;/filter&gt;
&lt;/invoke-target&gt;
...</pre>
<p style="text-align:center;">Figure 1 Registering for tag types in BlackBerry 10</p>
<p>When a “start” or “stop” tag is presented to the handset, then our application is launched if it’s not already running, and the tag contents are handled as shown in Figure 2 &#8212; where the payload of “start” or “stop” is extracted once we’ve verified that it’s of the correct type.</p>
<pre>...
void NfcListener::receivedInvokeRequest(const bb::system::InvokeRequest&amp; request) {

    QByteArray data = request.data();
    QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data);

    handleNdefRequest(ndefMessage);
}

void NfcListener::handleNdefRequest(const QtMobilitySubset::QNdefMessage ndefMessage) {

    QList::const_iterator ndefRecord;

    for ( ndefRecord = ndefMessage.begin(); ndefRecord != ndefMessage.end(); ndefRecord++) {
        if (ndefRecord-&gt;typeNameFormat() == QtMobilitySubset::QNdefRecord::ExternalRtd) {
            if (QString(ndefRecord-&gt;type()).compare("my.rim.com:myrecordtype") == 0 ) {
                emit raceTagDetected(QString(ndefRecord-&gt;payload()));
            }
        }
    }
}
...</pre>
<p style="text-align:center;">Figure 2 Handling a Start or Stop tag in BlackBerry 10</p>
<p>In the case of BlackBerry 7, registration is achieved in Java® by registering a listener for the specific NDEF message type as shown in Figure 3.</p>
<pre>...
    nfcManager = ReaderWriterManager.getInstance();
    nfcManager.addNDEFMessageListener(listener, NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype", true);
...</pre>
<p style="text-align:center;">Figure 3 Registering for tag types in BlackBerry 7</p>
<p>A similar behaviour is achieved for BlackBerry 7 through the implementation of the “<strong>onNDEFMessageDetected()</strong>” method of the “<strong>NDEFMessageListener</strong>” interface as shown in Figure 4.</p>
<pre>...
    public void onNDEFMessageDetected(NDEFMessage msg) {
        NDEFRecord[] records = msg.getRecords();
        int numRecords = records.length;
        if(numRecords &gt; 0) {
            byte[] payloadBytes = records[0].getPayload();
            try {
                String ascii_payload = new String(payloadBytes,"US-ASCII");
                Utilities.log("XXXX payload="+ascii_payload);
                if (ascii_payload.equals("start")) {
                    startTimer();
                }
                if (ascii_payload.equals("stop")) {
                    stopTimer();
                }
            } catch(UnsupportedEncodingException e) {
                Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
            }
        }

    }

...</pre>
<p style="text-align:center;">Figure 4 Handling a Start or Stop tag in BlackBerry 7</p>
<p>So, what we’ve achieved here is the ability to use an external NFC tag to trigger a process in our application. In this case it’s simply the starting and stopping of a timer, but it could be extended quite easily to, say, call a web service and integrate the event into a larger workflow process.</p>
<p>What does this look like in practice? Well, here’s a short video of the BlackBerry 10 application in action:</p>
<p style="text-align:center;"><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='480' height='360' src='http://www.youtube.com/embed/QZ5nABZcFuo?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p style="text-align:center;">[ <a href="http://www.youtube.com/watch?v=QZ5nABZcFuo&amp;feature=youtu.be" target="_new">YouTube link for mobile viewing</a> ]</p>
<h3><strong>Virtual Tag Emulation</strong></h3>
<p>Let’s get back to the original use cases. To implement the second one, we decided to have the BlackBerry handset emulate a virtual tag and allow the contents of the virtual tag to be read by an external NFC reader.<br />
What format of tag should be emulated by the handset? This is what we chose:</p>
<p><strong>1. Virtual tag emulated by the application</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;hh:mm:ss&#8221;</p>
<p>a. That is the time displayed on the handset in:<br />
Hours (hh)<br />
Minutes (mm)<br />
Seconds (ss)</p>
<p>The type of the virtual tag is exactly the same as for the “start” and “stop” physical tags for the very same reasons, except that the payload is a representation of the current race timer value (“hh:mm:ss”) as displayed by the application.</p>
<pre>...
void NfcListener::startTagEmulation(const QString &amp;tagData) {
    nfc_ndef_record_t *ndefRecord = makeCustomRecord(QString("my.rim.com"), QString("myrecordtype"), tagData);
    if (_emulateNdefMessage) {
        CHECK(nfc_delete_ndef_message(_emulateNdefMessage, true));
        _emulateNdefMessage = 0;
    }
    CHECK(nfc_create_ndef_message(&amp;_emulateNdefMessage));
    CHECK(nfc_add_ndef_record(_emulateNdefMessage, ndefRecord));
    CHECK(nfc_start_ndef_tag_emulation(_emulateNdefMessage));
...</pre>
<p style="text-align:center;">Figure 5 BlackBerry 10 &#8211; starting virtual tag emulation</p>
<p>As shown in Figure 5, starting tag emulation in BlackBerry 10 is quite simple. It just involves calling “<strong>nfc_start_ndef_tag_emulation()</strong>”. In addition we can use BPS (BlackBerry Platform Services) to determine when a read on the virtual tag has been successful, as shown here in Figure 6:</p>
<pre>...
void NfcListener::handleNfcEvent(bps_event_t *event) {
    uint16_t code = bps_event_get_code(event);
    if (NFC_VIRTUAL_TAG_SELECTION_EVENT == code) {
        emit tagEmulationSelectEvent();
    } else if (NFC_VIRTUAL_TAG_LEFT_EVENT == code) {
        emit tagEmulationLeftEvent();
    } else if (NFC_VIRTUAL_TAG_READ_EVENT == code) {
        emit tagEmulationReadEvent();
    }
}
...</pre>
<p style="text-align:center;">Figure 6 BlackBerry 10 &#8211; stopping virtual tag emulation</p>
<p>So, what we’ve achieved here is the ability to transmit live information from an application in the BlackBerry handset in real time to an external application via an NFC reader. The external application simply displays the time displayed by the BlackBerry application, but it could easily be extended to integrate with some larger workflow process.</p>
<p>Take a look at the video here for a demonstration of this on BlackBerry 10:</p>
<p style="text-align:center;"><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='480' height='360' src='http://www.youtube.com/embed/g58Xpnsqq4o?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p style="text-align:center;">[ <a href="http://www.youtube.com/watch?v=g58Xpnsqq4o&amp;feature=youtu.be" target="_new">YouTube link for mobile viewing</a> ]</p>
<p>If you’re interested, the virtual tag emulation functionality was tested using an NFC Reader attached to a PC controlled by a Python application using the “PyScard” (Python for Smart Cards) library available from <a href="http://pyscard.sourceforge.net/" target="_new">SourceForge.net</a>. (Python and Ruby are my favorite programming languages!)</p>
<p>The two versions of our NFC-enabled “Fun Run” applications are available with full source code from our GitHub repositories here:</p>
<p><a href="https://github.com/blackberry/Cascades-Community-Samples/tree/master/NfcRaceTimeWay" target="_new">https://github.com/blackberry/Cascades-Community-Samples/tree/master/NfcRaceTimeWay</a><br />
<a href="https://github.com/blackberry/Samples-for-Java/tree/master/NFC/NfcRaceTime7" target="_new">https://github.com/blackberry/Samples-for-Java/tree/master/NFC/NfcRaceTime7</a></p>
<p>Just in closing, it’s worth making one or two comments about the relative ease of developing applications to the same set of end user specifications in BlackBerry 10 Cascades™ versus BlackBerry 7 Java. I’ve been developing code in C/C++ for more years than I care to remember and for a shorter time in Java (but still since the language first saw the light of day), so I feel I’m qualified to make comparisons. I’ll be honest: I’ve found it much easier to develop applications using C/C++ and Cascades. The user interface elements are particularly easy to use, and I’ve found it possible to get a user interface up and running in Cascades much faster than I would have done in Java. It’s much easier to modify and extend since Cascades elements map directly to Qt/Cascades C++ classes and the SIGNAL() / SLOT() model makes it so easy to connect events to handlers.</p>
<p>I’m definitely sold on Cascades, Qt and C/C++!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/11782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/11782/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11782&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d86c7fdd0d15b754b2760af4536923b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdwrim</media:title>
		</media:content>
	</item>
		<item>
		<title>NFC Card Emulation with a dead battery</title>
		<link>http://devblog.blackberry.com/2012/04/nfc-card-emulation-with-dead-battery/</link>
		<comments>http://devblog.blackberry.com/2012/04/nfc-card-emulation-with-dead-battery/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 15:28:17 +0000</pubDate>
		<dc:creator>mdwrim</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[dead battery]]></category>
		<category><![CDATA[emulation]]></category>
		<category><![CDATA[low battery]]></category>
		<category><![CDATA[Near Field Communication]]></category>
		<category><![CDATA[nfc]]></category>
		<category><![CDATA[NFC card emulation]]></category>
		<category><![CDATA[NFC Card Transactions]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=8905</guid>
		<description><![CDATA[Find out the difference between "low battery" versus "dead battery" and how you may be able to provide NFC card emulation functionality in either situation.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8905&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://rimdevblog.files.wordpress.com/2012/04/nfc.jpg"><img src="http://rimdevblog.files.wordpress.com/2012/04/nfc.jpg?w=427&#038;h=640" alt="TITLE_IMAGE" title="nfc" width="427" height="640" class="aligncenter size-full wp-image-8910" /></a></p>
<p>Did you know that your NFC-enabled BlackBerry® smartphone may be able to process NFC transactions, such as payments, even when it has a completely dead battery? Smartphones which support NFC will continue to be able to provide NFC card emulation functionality when in &#8220;low battery mode&#8221; or, in some circumstances, even when the battery is completely dead.</p>
<p>Let&#8217;s explore what the difference between &#8220;low battery&#8221; versus &#8220;dead battery&#8221; is before we move on.</p>
<p><strong>Low battery mode</strong> starts when the smartphone OS turns off the user interface due to the battery being deemed &#8220;low&#8221;.  The smartphone appears to be off to the user, but internally, the Power Management Integrated Circuit (PMIC) is still on. <strong>Dead battery mode</strong>, by way of contrast, starts when there is no longer enough power in the battery to keep even the PMIC powered on.</p>
<p>How long low battery mode will last before moving into the dead battery state varies from smartphone to smartphone, but is typically at least four or five hours.</p>
<p>In low battery mode, all BlackBerry smartphones will continue to be able to provide NFC card emulation functionality.  But when it comes to dead battery mode, whether NFC card emulation will continue to work or not depends on the smartphone model; for instance, the BlackBerry® Curve™ 9380 smartphone and BlackBerry® Bold™ 9790 smartphone do support dead battery mode.  This mode is not supported on the BlackBerry® Bold™ 9900 smartphone and BlackBerry® Curve™ 9360 smartphone.</p>
<p>The user has no way of knowing just from looking at their smartphone if they are in low battery mode or have a completely dead battery.  Because of this, they have no way of knowing whether or not NFC transactions in card emulation mode will work or not in a given instance.</p>
<p>Developers have an API function called<br /> <i>SecureElementManager.setCardEmulationWhenPoweredOff(true|false)</i> which they can call to control whether or not card emulation will work or not when the battery is dead or has been removed.</p>
<p>You may also have noticed that the Near Field Communication options screen has a setting in the section entitled &#8220;Allow NFC Card Transactions&#8221; labelled &#8220;When Powered Off&#8221;.  This setting will also affect the behaviour of a device when in low battery or dead battery mode.</p>
<p>To learn more about NFC, check out our <a href="http://docs.blackberry.com/en/developers/deliverables/34480/Near_Field_Communication_1631111_11.jsp" target="_new">online developer documentation</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/8905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/8905/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8905&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/04/nfc-card-emulation-with-dead-battery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d86c7fdd0d15b754b2760af4536923b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdwrim</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/04/nfc.jpg" medium="image">
			<media:title type="html">nfc</media:title>
		</media:content>
	</item>
		<item>
		<title>There is always a clue – digging into NFC issues (Part 2)</title>
		<link>http://devblog.blackberry.com/2012/03/nfc-troubleshooting-part-2/</link>
		<comments>http://devblog.blackberry.com/2012/03/nfc-troubleshooting-part-2/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 14:28:45 +0000</pubDate>
		<dc:creator>mdwrim</dc:creator>
				<category><![CDATA[Case Studies & Success Stories]]></category>
		<category><![CDATA[Dev Con]]></category>
		<category><![CDATA[devcon europe]]></category>
		<category><![CDATA[Near Field Communication]]></category>
		<category><![CDATA[nfc]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=8642</guid>
		<description><![CDATA[Part 2 of this two-part blog post examines how issues can arise with NFC tags.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8642&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In my <a href="http://devblog.blackberry.com/2012/03/nfc-troubleshooting/" target="_new">previous post</a>, I began telling the story of a strange NFC issue I encountered during – of all things –a presentation by John Murray and myself at <a href="http://www.blackberrydevcon.com/europe" target="_new">BlackBerry® DevCon Europe</a> about developing NFC-enabled apps. As it turned out, an NFC tag on a flyer in the presentation room wasn’t scanning properly. What could be the issue?</p>
<p>Our first task was to establish whether or not we could read the content of the tags any way at all and if so, to determine just what that content was.</p>
<p>Now, an NFC tag is a smart card and it responds to ISO 7816-4 APDUs, so it’s possible to work with it at a lower level than would be the case when using the BlackBerry NDEFMessageListener Java® interface &#8211; which is how we’d normally seek to read an NFC tag from a BlackBerry® smartphone application. As such, armed with the NFC Forum specifications for NDEF tags types 1-4 in one hand, the ISO 7816-4 specs in the other, and a contactless card reader in errrrr&#8230;the other, we set to work.</p>
<p><span id="more-8642"></span></p>
<p>Our investigation proceeded on two fronts: John had been looking at a Python API for smart card developers called “pyscard” for a while and thought we could do something with that. We also contacted our own NFC product development team for advice, and they provided a BlackBerry smartphone app that they use to dump the content of tags to the device screen.</p>
<p>While sitting in the hotel bar drinking coffee and huddled around my laptop, it wasn’t long before John and I had a Python script running which was able to dump and decode the content of the tag. Through trial and error, we determined that we were dealing with a Type 2, tag and the decoded data produced by our script agreed with the data produced by the app our development team had provided. On examining the details carefully, we could see the problem with the tags as plain as day. Here’s part of what our script produced. Can you see the issue?</p>
<p><code>NDEF data:</code></p>
<p>TNF : 3 RFC 3986 ABSOLUTE URI<br />
Type Length : 1<br />
MB (Message Begin) : 1<br />
ME (Message End) : 1<br />
CF (Chunk Flag) : 0<br />
SR (Short Record) : 1<br />
IL (ID Length) : 0<br />
Payload Length (SR): 34<br />
Type : U<br />
Payload (hex) : 68 74 74 70 3A 2F 2F 6F 6E 2D 74 61 70 2E 6E 65 74 3F 74 3D 30 69 38<br />
34 76 69 65 71 38 7A 65 73 31 6E</p>
<p>The problem is that there’s a mismatch between the value provided for TNF (Type Name Format) and the data in the Type field.</p>
<p>TNF=0&#215;03 means the tag contains an “absolute URI” as defined in RFC 3986. When this value is specified, then the Type field should contain a valid URI and the payload should be empty. As we can see, however, the Type field contains “U” in this case.</p>
<p>Of the other values which TNF could take, a value of 0&#215;01 means the tag contains an “NFC Well Known Type”. Well known types are pre-defined record types and formats which the NFC Forum devised to support common use cases. When TNF=0&#215;01, the Type field contains a short code which indicates which of those well known types the payload represents. Values include “Sp” for smart poster, “T” for Text and “U” for URI. So as you can see, there are two ways of encoding a URI; either with TNF=0&#215;03 and an empty Type field or with TNF=0&#215;01 and Type=”U”. Clearly whatever tool was used to write the tags on the flyers has a bug, since these two distinct cases seem to have been mixed up so that we have the invalid combination of TNF=0&#215;03 and Type=’U’.</p>
<p>So, the mystery of the unreadable tag was solved! Hopefully this account provides some insight into a real-world issue and the activities involved in investigating such a problem.</p>
<p>Have fun with NFC!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/8642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/8642/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8642&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/03/nfc-troubleshooting-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d86c7fdd0d15b754b2760af4536923b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdwrim</media:title>
		</media:content>
	</item>
		<item>
		<title>There is always a clue – digging into NFC issues (Part 1)</title>
		<link>http://devblog.blackberry.com/2012/03/nfc-troubleshooting/</link>
		<comments>http://devblog.blackberry.com/2012/03/nfc-troubleshooting/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 16:16:21 +0000</pubDate>
		<dc:creator>mdwrim</dc:creator>
				<category><![CDATA[Case Studies & Success Stories]]></category>
		<category><![CDATA[Dev Con]]></category>
		<category><![CDATA[devcon europe]]></category>
		<category><![CDATA[Near Field Communication]]></category>
		<category><![CDATA[nfc]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=8636</guid>
		<description><![CDATA[Part 1 of a two-part blog post examining NFC, what can go wrong and how to fix it.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8636&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>My name is Martin and I’m part of the BlackBerry® Developer Relations team. I’ve been with RIM® for three years and have worked in software development in various capacities for 30 years in a wide range of industry sectors and on numerous computing platforms small and large. These days I specialize in Near Field Communication (NFC), a technology I find fascinating to work with and I hope to share some of my experiences with you through the Inside BlackBerry Developer’s Blog, starting with this – a two-part mystery.</p>
<p><a href="http://www.blackberrydevcon.com/europe" target="_new">BlackBerry DevCon Europe</a> in Amsterdam was my first BlackBerry conference and I have to say, I thoroughly enjoyed the experience. It was a great pleasure to meet developers who I’ve been working with by email but have never actually met in person.</p>
<p>Judging by the feedback received from attendees, the presentation I gave with John Murray, “DEV311 – How to develop an NFC enabled app,” was extremely popular. NFC is really a very large topic, especially when you start to move away from the simple use cases such as tag reading and into more technically-involved use cases, such as payment. It was a shame we were limited to a mere one hour. We could have talked about NFC all day!</p>
<p>However, there was an “incident” in the first of two NFC sessions which we presented, and it’s that incident that I want to write about here.</p>
<p><span id="more-8636"></span></p>
<p>The event organizers had placed flyers on the chairs in the room, advertising another event that John and I would be at. The event is a NFC Hackathon to be held in London the weekend of March 24th and which our carrier partner O2 is sponsoring. (We’d love to see you there. You can find details at the following web site: <a href="http://www.isobar.com/en/news/2012/2/3/create-london" target="_new">http://www.isobar.com/en/news/2012/2/3/create-london</a>)</p>
<p>The flyers had NFC tags fixed to the back of them and John and I knew nothing about this, so we were somewhat surprised when a member of the audience – as the very first question in our first session – said, “So why can’t my BlackBerry® Bold™ 9900 smartphone read this tag?!”<br />
As anyone who has ever presented or done live demos of anything will know, things do go wrong from time to time and that’s all part of the fun. But this one came out of nowhere and we were, to put it mildly, a little stumped by this question initially!</p>
<p>Problems tend to indicate opportunities though, so given that I was presenting on the topic of tag reading when the question was asked, whilst I couldn’t say anything definite at the time (issues like this need technical investigation, as you’ll see), it did give me the opportunity to talk about standards and degrees of compliance. It’s a fact that of the many makes and types of NFC tags that are out there in the world, some comply 100% with the relevant NFC Forum and ISO standards whilst some do not. We’ve worked hard at RIM to ensure our products comply with those standards since for a technology like NFC to gain wide spread adoption, inter-operability between tags and devices and between devices themselves is absolutely crucial. That said, even if a tag complies fully with the technical standards, it’s still possible to write non-standard content to it, so we all have a responsibility to comply with those standards, not just the device vendors.</p>
<p>Having made my small speech about standards, we moved on and completed the presentation. But the story didn’t end there because neither myself nor John are the kind of people to be satisfied with anything less than a complete and technically accurate answer to issues of this sort! So we collected samples of the flyers with their tags and took them back to the hotel where we proceeded to analyse their content. We call this “NFC Forensics!”</p>
<p>The second part of this story will be posted tomorrow; until then send us your thoughts about what you think happened!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/8636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/8636/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8636&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/03/nfc-troubleshooting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d86c7fdd0d15b754b2760af4536923b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdwrim</media:title>
		</media:content>
	</item>
	</channel>
</rss>
