Demonstration of possible usage of the the NFCController class.

NFC SmartPoster example

Demonstration of possible usage of the the NFCController class.

The application creates a smart poster record and sends it when a connected peer requests it. The smart poster record generated contains:

  • A URI: https://www.mbed.com
  • A title: "mbed website"
  • An action: EXECUTE which asks the peer to open the URI.

Running the application

Verification of the sample application can be seen on any a smartphone with an NFC reader. After running you will be able to read the tag with an NFC tag reader application.

Information about activity is also printed over the serial connection - please have a client open. You may use:

Tera Term - https://ttssh2.osdn.jp/index.html.en

This example is known to work on boards connected to a PN512 shield.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Wed Sep 26 15:01:02 2018 +0100
Parent:
0:9a16c3f036b0
Child:
2:803d4e3438ba
Commit message:
Merge pull request #13 from ARMmbed/mbed-os-5.10.0-oob

Mbed os 5.10.0
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-nfc

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/README.md	Mon Sep 24 17:09:42 2018 +0100
+++ b/README.md	Wed Sep 26 15:01:02 2018 +0100
@@ -14,10 +14,6 @@
 
 Verification of the sample application can be seen on any a smartphone with an NFC reader. After running you will be able to read the tag with an NFC tag reader application.
 
-Information about activity is also printed over the serial connection - please have a client open. You may use:
-
-- [Tera Term](https://ttssh2.osdn.jp/index.html.en)
-
 This example is known to work on boards connected to a PN512 shield.
 
 ## Building instructions
--- a/main.cpp	Mon Sep 24 17:09:42 2018 +0100
+++ b/main.cpp	Wed Sep 26 15:01:02 2018 +0100
@@ -103,15 +103,10 @@
     /* ------------------------------------------------------------------------
      * Implementation of NFCRemoteInitiator::Delegate
      */
-    virtual void on_connected()
-    {
-        printf("Connected\r\n");
-    }
+    virtual void on_connected() { }
 
     virtual void on_disconnected()
     {
-        printf("Disconnected\r\n");
-
         // reset the state of the remote initiator
         _nfc_remote_initiator->set_delegate(NULL);
         _nfc_remote_initiator.reset();
@@ -120,15 +115,10 @@
         _nfc_controller.start_discovery();
     }
 
-    virtual void parse_ndef_message(const Span<const uint8_t> &buffer)
-    {
-        printf("Received an ndef message of size %d\r\n", buffer.size());
-    }
+    virtual void parse_ndef_message(const Span<const uint8_t> &buffer) { }
 
     virtual size_t build_ndef_message(const Span<uint8_t> &buffer)
     {
-        printf("Building SmartPoster message\r\n");
-
         // build the smart poster object we want to send
         SmartPoster smart_poster(
             URI(URI::HTTPS_WWW, span_from_cstr("mbed.com"))
@@ -151,7 +141,6 @@
      */
     virtual void on_discovery_terminated(nfc_discovery_terminated_reason_t reason)
     {
-        printf("Discovery terminated: %u\r\n", reason);
         if(reason != nfc_discovery_terminated_completed) {
             _nfc_controller.start_discovery();
         }
@@ -159,8 +148,6 @@
 
     virtual void on_nfc_initiator_discovered(const SharedPtr<NFCRemoteInitiator> &nfc_initiator)
     {
-        printf("Initiator discovered\r\n");
-
         // setup the local remote initiator
         _nfc_remote_initiator = nfc_initiator;
         _nfc_remote_initiator->set_delegate(this);
--- a/mbed-os.lib	Mon Sep 24 17:09:42 2018 +0100
+++ b/mbed-os.lib	Wed Sep 26 15:01:02 2018 +0100
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#3fb5781af180c32a6062f050d59cdf93654b3e9f
+https://github.com/ARMmbed/mbed-os/#610e35ddc6d59f153173c1e7b2748cf96d6c9bcd