Testing NFC apps
BlackBerry devices that support near field communication (NFC) can read a smart tag, a smart accessory, or another NFC-enabled device. NFC technology is designed to transfer small amounts of data over a short distance. For example, you could provide pairing information for a Bluetooth accessory. You can create NFC tags, populate them with data, and present them to the simulated device. The default tag type is Blank, which means that the tag has no information and is writable by the device. You can also use Text, URI, or Smart Poster tags to perform the following tasks:
- Provide a URL where a user can retrieve more information about an advertisement on a smart poster, such as a movie or a coupon.
- Provide pairing information for a Bluetooth accessory.
- Provide identification information for a smart dock.
Create a new NFC tag
- In the controller, click NFC.
- Choose an NFC tag type and enter the required information.
- If you want your app to be able to write to the tag, select the Writable check box.
Simulate tapping an NFC tag on a device
- In the controller, in the NFC dialog box, select your tag.
- Click Present.
- To simulate moving the tag away from the simulator, click Remove.
Simulate a P2P NFC connection
- Ensure that you have two simulators running.
- In the controller, click NFC.
- Enter the IP Address of the simulator you wish to connect to and click Connect P2P.
- To disconnect, click NFC > Disconnect.
Near Field Communication (NFC) support
NFC defines standards for smartphones to establish two-way radio communication for transmitting a small amount of information over a short distance, such as an inch or two. For example, you can use NFC for monetary transactions, data exchange, and a simplified setup of more complex communications, such as Wi-Fi.
The provider device creates an RF carrier field and the target device answers by modulating the existing field. In this mode, the target device draws operating power from the provider's field, such as between a smartphone and an unpowered NFC tag. Tags may be read-only or read-writable. The simulator can emulate a target as described in the NFC tag emulation mode and NFC smart poster mode sections below.
Two devices can communicate as peers, as described in the NFC P2P support section below, by running two simulators concurrently. Each simulator alternates between acting as a provider (generating its own transmitting field) and a target (deactivating its field while listening).
SimNFCProvider simulates OpenNFCProvider and the device driver. It implements NFC Provider APIs, and communicates with the other two NFC components in the same way as OpenNFCProvider.
NFC simulation GUI
The GUI provides a means to simulate a peer device in an NFC simulation:
When simulating a tag reader/writer on the device, the GUI acts as a tag.
When simulating tag emulation on the device, the GUI acts as a tag reader/writer.
The NFC simulation GUI also allows you to control and configure NFC simulation.
The connector simulates the NFC connection and events between the device and its peer in NFC simulation. For tag reader/writer and tag emulation, it connects the simulator with the GUI. For peer-to-peer simulation, it connects two simulators to each other.
NFC smart poster support
NFC smart posters are similar to QR codes. Users can receive additional information directly to their smartphone. The following describes the passive communication simulator's smart poster tag implementation:
You can access these commands from the controller using the NFC menu.
To present a smart poster tag:
In the NFC controller, choose Smart Poster from the drop-down list. When Smart Poster is selected, you are prompted for a URI (mandatory), Title (optional), and Action (optional).The following are possible values for Action:
- No action
- Launch the browser
- Save for later (for example, bookmark a URI)
- Edit for editing (for example, open the URI in a URI editor)
To receive a smart poster tag in write command.
This is handled in a manner similar to that of a virtual text tag, the difference is that a smart poster may contain URI, text (Title) and Action.
To receive a virtual smart poster tag (emulation mode).
This is handled in a similar manner as a virtual text tag. The difference is that a virtual smart poster tag may contain URI, text (Title) and Action.
NFC tag emulation
Emulating an NFC tag is similar to the tag read/write emulation. You need to run the simulator and the controller. To test emulation, you must run an application on the simulator that emulates the virtual tag, and set the controller to listening mode. To set up the controller, click NFC > Listen for virtual tag.
- Select Emulate tag.
- Append a record (this creates the message for the virtual tag).
- Click Register.
The controller displays a dialog box that indicates a virtual tag is detected. You can now view the content of the tag.
To use a second NFC application on the simulator, run the application on the simulator, and set the controller to listening mode. When the application calls the appropriate APIs to register for a virtual tag (or for tag emulation), the tag appears on the controller.
NFC Peer-to-Peer (P2P) support
In P2P mode, two NFC devices can exchange data. When there is a small amount of data to be transferred between the devices (such as a URL), the data is transferred using the NFC SNEP protocol. When there is a large amount of data (such as a picture), typically a Bluetooth connection is established using NFC (also called connection handover), and then the data is transferred over the Bluetooth connection. Currently, the simulator supports only SNEP for P2P.
A physical connection between two devices
Connection between a SNEP client and SNEP server