Wiki

Clone wiki

Pipsta / Adding Bespoke Methods to the Pipsta NFC Android App

Difficulty Level

pipsta_mono.pngpipsta_mono.pngpipsta_mono.pngpipsta_mono_empty.pngpipsta_mono_empty.png

  • This tutorial assumes the user has some Android phone user experience.
  • Initiative may be required in order for the user to navigate the idiosyncrasies of their own Android device.

Time to Complete

pipsta_mono.pngpipsta_mono.pngpipsta_mono_empty.pngpipsta_mono_empty.pngpipsta_mono_empty.png

  • Time taken to make changes to the Android App's functionality are minimal.

Introduction

In this tutorial, we will add a further, simple method to those already available on the Android app. For clarity, this extra method is intentionally minimal and simple.

Background

By default, the Android Pipsta NFC App permits the use of two 'Send to Pi' methods:

  • pipsta.qr - for generating QR-Codes
  • pipsta.banner - for generating banners

In both cases, the system operates as follows: NFC_server_sys.png

pipsta_methods.txt

The Pipsta NFC Android app populates the Send To Pi screen according to which function is selected in the drop-down list box. In turn, the list box, and screens’ contents are defined in a simple text file named “pipsta_methods.txt”:

#!

method=pipsta.qr,description="Print as QR code using this data",field_title="QR Code Data",field_default="012345456789"
method=pipsta.banner,description="Print as a banner using this data",field_title="Banner Text",field_default="Hello World"

It can be seen how each of these parameters and values are used to populate the screens for these methods: Screenshot_2015-04-22-16-25-54.png Screenshot_2015-04-22-16-27-41.png

'pipsta_methods.txt' can be found using a file explorer app on the Android device (e.g. ‘My Files’) in the location: /storage/emulated/0/pipsta

Note that the file explorer app and the file location itself may vary depending on the phone hardware and operating system version.

Adding your own functionality to the Android App is a simple matter of adding an additional line to this file.

Example

In this example, we will add a new Pipsta method ‘pipsta.basic’. The system functionality is as follows:

  • User enters some text to be printed
  • Text data is sent via NFC to the Pipsta Printer
  • The Raspberry Pi polls the printer to see if NFC data is waiting
  • The Raspberry Pi retrieves the data from the Pipsta Printer
  • The Raspberry Pi processes the new method, passing the data across to a new script (TBD)

In terms of the modifications required to the Pipsta NFC Android app, all we need to do is add a line to the pipsta_methods.txt file. The simplest way of doing this is to connect the Android device to a computer via USB, navigate to and edit this file as follows:

#!

method=pipsta.qr,description="Print as QR code using this data",field_title="QR Code Data",field_default="012345456789"
method=pipsta.banner,description="Print as a banner using this data",field_title="Banner Text",field_default="Hello World"
method=pipsta.basic,description="Basic Print",field_title="Text to be printed",field_default="Hello World via NFC"

After saving the file and exiting the editor, launch the Pipsta NFC Android app again and bring-up the ‘Send To Pi’ screen. You should now find the extra method in the drop-down list box:

Screenshot_2015-04-22-16-44-47.png

Selecting this method will populate the screen as follows:

Screenshot_2015-04-22-16-48-08.png

It can be seen that the App now has a new screen tailored to the new method.

Next Steps

So far, we have only added functionality to the Pipsta NFC Android App. In order to have a full, working system, we now need to add functionality to the Daemon running on the Raspberry Pi and add a script for it to call. This is done in:

End of Document

Updated