Control object for the pps-spp service

pps-spp; any app
pps-spp; any app
Note: This type of object is known as a server object, a special PPS object designed for point-to-point communication between a server and one or more clients. For details, see "Server objects" in the Persistent Publish/Subscribe Developer's Guide.


The pps-spp service supports any HTML5 application (e.g., PandoraLink) that needs to access Bluetooth SPP data. The server object will accept commands to open and close one SPP stream for a client. Once the SPP connection is open, the service will notify the client when new data has been read from SPP. This object also supports a command to write data to SPP.


Besides using this PPS server object, an HTML5 app would also need to use the qnx.bluetooth and qnx.bluetooth.spp JavaScript extensions to start or stop the SPP service on a paired device before communicating with the pps-spp service. For more information, see WebWorks JavaScript Extensions (CAR 2.0—deprecated) in HTML5 and JavaScript Framework.

Apps may also use the /pps/services/bluetooth/control object to issue Bluetooth commands for setting the accessibility level for devices, initiating pairing, and so on.

Message/response format

Commands sent to the /pps/services/bluetooth/spp/spp object are of the form:


Responses always reflect the command_string and ID_number that were sent in the message, along with any errors:


Note: The id field can be omitted if there's no need to get a response back for the message.

Messages sent by the client

Command Parameters Description
open_stream dat
JSON-encoded object that holds two parameters:
  • mac—MAC address of the device
  • uuid—UUID of the SPP server
Open an SPP stream.
close_stream n/a Close the SPP stream.
write_data base64Data Write Base64-encoded data to the stream.

Responses returned by the server

Besides returning the client's message and ID, the server can also send a new_data response:

Response Parameters Description
new_data base64Data Indicates new data was read from the SPP stream.


These examples show how to open an SPP stream, write "Hello World!", then close the stream.


These examples assume that you've already opened an SPP connection to a device using the connect_service Bluetooth command. For example:

echo "command::connect_service\ndata::D5:DA:8E:43:ED:68\n data2::0x1101:453994D5-D58B-96F9-6616-B37F586BA2EC" >> /pps/services/bluetooth/control

For more information on Bluetooth commands, see the entry for /pps/services/bluetooth/control in this reference.

  1. We need to force the shell to keep the file descriptor open (because this is a server object):

    # exec 3<> /pps/services/bluetooth/spp/spp

  2. Issue the command to open the stream, along with a cat so we can see the response:

    # echo "msg::open_stream\nid::1\ndat:json:{\"mac\":\"D5:DA:8E:43:ED:68\", \"uuid\":\"453994D5-D58B-96F9-6616-B37F586BA2EC\"}" >&3; cat <&3

    The spp object should show the response:

  3. Next we write "Hello World!" to the SPP stream. Remember that the caller will need to Base64-encode the data before sending the message:

    # echo "msg::write_data\nid::2\ndat::SGVsbG8gV29ybGQh" >&3; cat <&3

    Again, the spp object will show the response:

  4. Finally, we send the close_stream message to close the stream:

    # echo "msg::close_stream\nid::3\ndat::" >&3; cat <&3

    And the object should look like this: