Control object for the pps-spp service
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.
Commands sent to the /pps/services/bluetooth/spp/spp object are of the form:
msg::command_string\nid::ID_number\ndat::command_parameters
Responses always reflect the command_string and ID_number that were sent in the message, along with any errors:
res::command_string\nid::ID_number\nerr::errno_number
Command | Parameters | Description |
---|---|---|
open_stream |
dat
JSON-encoded object that holds two parameters:
|
Open an SPP stream. |
close_stream | n/a | Close the SPP stream. |
write_data | base64Data | Write Base64-encoded data to the stream. |
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.
# exec 3<> /pps/services/bluetooth/spp/spp
# 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:
@spp res::open_stream id::1
# echo "msg::write_data\nid::2\ndat::SGVsbG8gV29ybGQh" >&3; cat <&3
Again, the spp object will show the response:
@spp res::write_data id::2
# echo "msg::close_stream\nid::3\ndat::" >&3; cat <&3
And the object should look like this:
@spp res::close_stream id::3