Skip to content
sitronTe edited this page Aug 13, 2015 · 3 revisions

Programming Lab Code URI Protocol

This is a simple text based protocol for transfer of either URIs that locate Processing sketches on the Internet or actual Processing code. The protocol is introduced into the project release 2.1.0.

Version

The protocol current version is 0.1

Message Flow

The protocol start when PLCUP/0.1 is sent from the device that require the code or URI. The last three characters here identify protocol version. The entire start string can be sent anywhere within a message, and should cause the receiving party to start the code/URI exchange. It is however strongly encouraged to allways start on a new line when sending it.

Newline characters should only be used to signify an end of message line. The communication should progress as this:

Request :

  • PLCUP/0.1 - Initiate protocol. The requesting party should set a timeout to avoid waiting for answers indefinately in case other party does not support the protocol.

Response :

  • PLCUP COD - Can deliver code.

    | PLCUP URI - Can deliver URI.

    | PLCUP C/U - Can deliver both code and URI.

    | PLCUP NON - Can not deliver anything.

    |PLCUP ERR - Error. Intended to show that protocol version is not supported.

In case response is PLCUP NON or PLCUP ERR, no further queries are expected.

In any other case, the responding unit should start a timeout to stop the protocol in case the requesting party does not wish to use the received data. To query the actual data, communcation should progress like this:

Request:

  • PLCUP G COD - Ask for code.

    | PLCUP G URI - Ask for URI.

Response:

  • PLCUP ERR - Could not deliver queried data.

    | PLCUP BEG - Begin data transfer.

    `\nDATA\n`+ - One or more lines of data (Single URI or code line). 
    
    `PLCUP END` - End data transfer.
    

After this response, no further communication over the protocol is expected.

Use In App

The protocol is by default NOT ENABLED. It can be enabled by going to settings, and check out the Enable PLCUP checkbox. The setting PLCUP timeout is given in seconds, and refers to how long after initial contact the app should wait before reporting protocol failure. The timer is reset on every message the app receives from connected device.

When loading URIs or code from app, the InterfacesInc.pde file is allways included. This is the same as when loading with URIs from the web in the normal fashion.

Use In Arduino

The protocol has been implemented for Arduino. It has been introduced as a part of PLabBT library. Implementing files are PLCUP.h and PLCUP.cpp. Both PLabBTSerial and PLabBTCallback uses this support.

To simply use, install this library, as described by Arduino.

Examples that show Arduino code are located in PLabExamples/examples/13.Bluetooth/ and all contain PLCUP in their name. To get these examples in the Arduino examples menu, copy the folders to the library under a subfolder you call examples.

Clone this wiki locally