Building and deploying the Cordova PPS Demo

The Cordova PPS demo is delivered as a separate Cordova component. You can build the demo to learn how to create a project, install a plugin, and use Persistent Publish/Subscribe(PPS) objects with an HTML5 app.

About the Cordova PPS demo

If you are using a QNX SDK for Apps and Media image, the steps regarding configuring the sys.acl, sys.res, and pps.conf files are already completed for you. In fact, the image contains the Cordova PPS Demo app installed. If you choose, you can recreate the application and deploy it onto the image. Before you deploy the app you build, it's a good idea to remove the previous version of the Cordova PPS Demo using the bar-uninstall command.

Note:

To run this demo, ensure that you have installed both the QNX SDK for Apps and Media, and the HTML5 SDK. The code for the HTML5 SDK is located at: HTML5 SDK install location/html5sdk/demo.

For more information, see The HTML5 Development Environment.

The instructions below describe how to create, deploy, and launch the Cordova PPS Demo app. After you have completed these tasks, you can use the instructions you followed as a model for other HTML5 projects.

Host system

On your host system, use the files in the demo folder as a template to create the demo app:

  1. In a command-line window, navigate to the directory where you installed the HTML5 SDK:
    • On Windows:
      cd HTML5 SDK install location\html5sdk
    • On Linux:
      cd HTML5 SDK install location/html5sdk
  2. Create the app template using the create command:
    • On Windows:
      cordova\cordova-qnxcar\bin\create CordovaPPSdemo
    • On Linux:
      ./cordova/cordova-qnxcar/bin/create CordovaPPSdemo
  3. Copy all the files from the www/ directory into the newly created app's www directory:
    • On Windows:
       xcopy /E demo\www CordovaPPSdemo\www
    • On Linux:
      cp -R ./demo/www/* CordovaPPSdemo/www
  4. Add the required plugins using the plugman install command:
    • On Windows:
      plugman install --platform blackberry10 --project ./CordovaPPSdemo
                      --plugin ./demo/com.qnx.demo
    • On Linux:
      plugman install --platform blackberry10 --project ./CordovaPPSdemo
                      --plugin ./demo/com.qnx.demo
  5. Build and package the app using the build command with the debug option.
    • On Windows:
      .\CordovaPPSdemo\cordova\build debug
    • On Linux:
      ./CordovaPPSdemo/cordova/build debug
    Note:

    The generated BAR file is located at .\CordovaPPSdemo\build\device\qnxcarapp.bar (on Windows) and ./CordovaPPSdemo/build/device/qnxcarapp.bar (on Linux).

    The .bar file is called qnxcarapp by default. If you manage multiple projects, consider renaming the .bar file to match your app name . For more information, see Packaging an HTML5 app.

Target system

On your target system:

  1. Deploy the app on the target using one of the following options:
    • You can use a USB stick to deploy the .bar file to the target. Copy the qnxcarapp.bar file from the previous step to your USB stick, and insert the stick into your target. Then, on your target, run the following command to deploy from your USB stick:
      /scripts/bar-install /fs/usb0/qnxcarapp.bar
    • If your target and host are on the same network, use a tool such as FTP or SCP to transfer the qnxcarapp.bar file to the \tmp directory on the target. Then, run the bar-install command as follows:
      /scripts/bar-install /tmp/qnxcarapp.bar
    When the bar-install command is finished, it will display output like the following:
    >> Added PPS entry 
    CordovaPPSdemo.testDev_dovaPPSdemod339185a::native/default-icon.png,
    Cordova PPS Demo,,,auto,,
    Make sure you record the filename (in this example: CordovaPPSdemo.testDev_dovaPPSdemod339185a). You will need it when you specify the access.
  2. Add the following entries to the /base/etc/pps.conf file to initialize the PPS object:
    qnx/demo
    0:0:0660:O_CREAT
    user::rw
    group::rw
    other::rw
    mask::rw
  3. Set up the Authorization Manager (authman) configuration. To do this, in the /etc/authman/sys.acl file declare the access_demo capability, and the permissions to the relevant PPS objects:
    access_demo
    ACL opt rwx:rw /pps/qnx/
    ACL opt rwx:rw /pps/qnx/demo
  4. Add the following entry to specify the access for the capability you declared in the previous step in the /etc/authman/sys.res file. Use the filename you recorded in Step 1 above:
    access_demo
    deny *
    allow CordovaPPSdemo.testDev_dovaPPSdemod339185a
  5. After you finish modifying the pps.conf, sys.acl, and sys.res files, reset your target. For more information about Authorization Manager, see Authorization Manager (authman) in the System Services Reference.
  6. On your target, start and run the app. If you have an HMI running, tap Cordova PPS demo; otherwise type the following command at the command prompt of the target:
    # launch CordovaPPSdemo
For information about using the Cordova PPS App, see "Cordova PPS Demo" in the User's Guide.