NXP NFC 3D App

Sends board info to a cloud server, and streams sensor data to a webapp connected via softAP. The text on the LCD display can be updated via the webapp or from the cloud server.

API Features Demonstrated

Platforms

This app works on:

Requirements and Prerequisites

This app requires an NXP-SCCK with NFC tag, and a smartphone/tablet with NFC support.

Resources

The file nfc3d.ini is used to initialize the device. This is packaged with the .zap file downloaded to the device.

Resources include the Zentri cloud certificate, and html and javascript for the web app and associated 3D model.

Description

This app demonstrates:

Usage Instructions

Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.

This app assumes your ZentriOS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the ZentriOS terminal, run the commands:

network_up -s
save

See the Wi-Fi Command API documentation for network_up and save.

Load the app.

The ZentriOS terminal displays output similar to the following:

> Starting NFC 3D Demo ...
- Initializing cloud services
Connected to cloud
[Success]
- Initializing SoftAP and HTTP Server
Display text updated
[Success]
- Initializing NFC tag
[Success]

Demo ready.

Instructions:
1. Download NFC Tag reader app
  - From Android phone: Google Play: search: NXP TagInfo
2. Start app and select the 'NDEF' tab
3. Place phone over NFC tag
4. Click provided link in app
5. Follow instructions on webpage

Note that you may be able to move directly to the cloud app in the browser, by simply opening a web browser and scanning the device NFC tag. This depends on your mobile device configuration.

Otherwise, using an Android mobile device, from Google Play download and install the NXP TagInfo app.

When the NXP TagInfo app successfully scans the NFC tag on the NXP Cloud Connectivity Kit (CCK), it displays output similar to the following:

Touch the link displayed in the URI record URI field to go to the Zentri cloud service for this app.

The first page of the cloud service shows device details that the nfc3d app sends periodically to the cloud service:

Scroll down to the second page for a control to update the text shown on the NXP CCK LCD display. Type in text and click update to send the new text to the device.

The page also provides instructions for viewing the 3D Demo web app. Follow the instructions to connect to the device Soft AP and view the web app served from the device.

The web app displays data streamed from the device. It uses the accelerometer sensor to show a representation of the orientation of the Zentri module plugged into the CCK. It also displays the temperature calculated from the device thermometer sensor:

When you connect to the soft AP, the ZentriOS terminal output is similar to the following:

[2016-01-04 | 03:08:48: 34:23:BA:F6:E0:FE associated]
> [2016-01-04 | 03:09:43: Opened: 1]
> Accelerometer update interval: 100
Stream listener registered, streaming data
Thermometer stream listener registered, streaming data
Thermometer stream listener unregistered
Stream listener unregistered
[2016-01-04 | 03:11:23: Closed: 1]

Move the NXP CCK around, and its position is mirrored in real time by the 3D model displayed in the web app.

Implementation

main.c

Manages initialization.

zn_app_init

cloud_websocket.c

Manages communication via websocket between device and cloud service.

Sends JSON data to cloud. The data includes various device details.

Reads JSON data from cloud, containing LCD message updates.

Declares websocket stream handle websocket_handle shared by several functions

cloud_init

cloud_post_update

cloud_connect_event_handler

network_event_handler

websocket_disconnect_handler

attempt_reconnect

websocket_rx_handler

Responds to a receive event with JSON data from the cloud service - parses the LCD message from the JSON

json_parse_reader

Reads websocket stream JSON data from cloud into the JSON config buffer. The JSON data contains LCD message text.

periodic_post_event_handler

write_setting

write_tag_read_count

write_lcd_message

write_ap_clients

local.c

Provides functions for sensors, LCD display and Soft AP.

local_init

local_set_lcd_msg

softap_event_handler

initialise_display

initialize_sensors

accelerometer_stream_callback

Depending on the stream method:

thermometer_stream_callback

Depending on the stream method:

display_stream_callback

For stream method HS_STREAM_READ:

nfc_tag.c

nfc_tag_init

generate_204.c

HTTP_SERVER_DYNAMIC_PAGE callback for /generate_204 page is generate_204_callback

generate_204_init

generate_204_callback

Source

See:

Settings:

See also: