Deploying Kanzi Connect applications to embedded devices

Building and Deploying to Android from Kanzi Studio

To build and deploy a Kanzi Connect application to Android device from Kanzi Studio:

  1. Connect your Android device to your computer.

  2. In Kanzi Studio open the Kanzi Studio project of the application you want to deploy to your Android device and select File > Export > Build Android Package. Kanzi Studio builds the application source code, creates .apk package, and installs the package to your Android device.

Building Kanzi Connect applications from the command line

Before you can build a Kanzi application for your target platforms, set up and configure the Kanzi build environment for your target platforms. The build environment includes tools that the Kanzi build system uses to build your application for your target platforms.

Kanzi Connect build scripts rely on system environment variables on all build platforms. The most important are:

  • KANZI_HOME that the Kanzi build scripts use

  • KANZI_CONNECT_SDK that the Kanzi Connect build scripts use

To set environment variables:

  • On Windows, you set these variables during the installation of Kanzi Connect.

  • On Linux, you can set these variables with the helper script <KanziConnectInstallation>/SDK/setup_env.sh.

Some platforms require you to set specific environment variables. For example, Kanzi Connect scripts for building applications for Android require ANDROID_SDK_HOME to be set, while scripts for building for QNX require QNX_HOST to be set.

Building Kanzi Connect applications using a Python script

To build Kanzi Connect applications using a Python script:

  1. In Kanzi Studio main menu select File > Open Kanzi Command Prompt or open the terminal on Linux.

  2. In the Kanzi Connect SDK directory run the script build_app.py.

    Syntax

    build_app.py [--config [Build configuration]]
                 [--gfx_api [Graphics system API]]
                 [--project-name [Name of module to build]]
                 [--gradle_archs [Gradle architectures to build]]
                 [-jobs [N]]
                 [-v]
                 [--dynamic]
                 <path>
                 <platform>
    

    Parameters

    <path>

    The path to the Application directory of the application that you want to build.

    <platform>

    The platform for which you want to build the application.

    --config

    (Optional) The build configuration type:

    • Release and GL_vs2015_Release_DLL build the application with compiler optimizations enabled. This option builds smaller files than the Debug option. Use this option for production purposes. The default value is GL_vs2015_Release_DLL.

    • Debug and GL_vs2015_Debug_DLL build the application with disabled compiler optimizations and contains full debug information that you can use with a debugger. This option builds larger files and debug applications run slower. Use this option for development purposes.

    --gfx_api

    (Optional) The graphics system to use:

    • ES3 builds the application with OpenGL ES 3.0

    • GL builds the application with OpenGL

    --project_name

    (Optional) The name of the module to build. Case sensitive.

    --gradle_archs

    (Optional) The Gradle architectures to build. If you pass more than one architecture name, the script sequentially builds all architectures that you select. These architectures are available:

    • armeabi-v7a

    • arm64-v8a

    • x86

    • x86_64

    --jobs

    (Optional) The number of concurrent build jobs. The default is 2.

    -v

    (Optional) Print what the script is doing.

    --dynamic

    (Optional) Build dynamic libraries. For most platforms Kanzi Connect requires dynamically linked libraries. The build scripts by default use static linking. Android ANT workflow and Integrity OS builds use static linking in Kanzi Connect applications.

    Examples

    To build the Cluster example application with the Debug configuration for Android Gradle workflow.

    build_app.py --config Debug examples/Cluster/Application android_gradle
    

    To build the IVI example application with the GL_vs2015_Release_DLL configuration for Windows.

    build_app.py --config GL_vs2015_Release_DLL examples/IVI/Application Win32 --dynamic
    

    To build the ControlPanel example application with the Release configuration for the Android Ant workflow.

    build_app.py examples/ControlPanel/Application android
    

    To build the HUD example application with the Release configuration for QNX 7.0, using the dynamic libraries.

    build_app.py examples/Cluster/Application qnx700_screen_aarch64 --dynamic
    

    To build the Android Kanzi Connect server with the Release configuration for the Android gradle with the aarch64 eabi.

    build_app.py Examples/Server/Demo/Application --gradle-archs arm64-v8a android_gradle
    

    To build the Kanzi Connect server with the default (Release) configuration for Windows.

    build_app.py sources/Server win32
    

Building Kanzi Connect applications using a Scons script

  1. In Kanzi Studio main menu select File > Open Kanzi Command Prompt or open a terminal on Linux.

  2. In the directory of your Kanzi Connect application configuration directory, run the scons command with the build parameters.

    Syntax

    scons <gfx_api> <type> project_name=<name> <--dynamic>

    Parameters

    gfx_api

    (Optional) The graphics system to use:

    • ES3 builds the application with OpenGL ES 3.0

    • GL builds the application with OpenGL

    type

    (Optional) The build configuration type:

    • Release builds the application with compiler optimizations enabled. The release option builds smaller files than the debug option. Use this option for production purposes. Default value.

    • Debug builds the application with disabled compiler optimizations and contains full debug information you can use with a debugger. The debug option builds larger files and debug applications run slower. Use this option for development purposes.

    name

    (Optional) The name of the module to build. Case sensitive.

    --dynamic

    (Optional) Build dynamic libraries. For most platforms Kanzi Connect requires dynamically linked libraries. The build scripts by default use static linking. Android ANT workflow and Integrity OS builds use static linking in Kanzi Connect applications.

    Examples

    To build an application with the default settings as specified in config.py and SConstruct configuration files.

    scons
    

    To build the Release version of an application with the OpenGL ES 3.0 graphics library.

    scons ES3 Release
    

    To build the Debug version of an application with the OpenGL graphics library and dynamic libraries.

    scons GL Debug --dynamic
    

    Builds the Debug version of an application with the OpenGL ES 2.0 graphics library from the Kanzi Studio project named MyProject.

    scons ES2 Debug project_name=MyProject
    

    Scons builds the Kanzi application source code and binary files in the <ProjectName>/Application/output directory.

Configuring Kanzi Connect application to connect to a Kanzi Connect Server running on another device

Kanzi Connect applications read the connection parameters from the connection.xml in the working directory of the application. On Windows, if that file is not available, Kanzi Connect creates it automatically. On all the other platforms, the file must be present when a Kanzi Connect application runs.

On Android, when you build a Kanzi Connect application, Kanzi Connect includes in the APK the connection.xml file from the <ProjectName>/Application/bin directory. You can override the settings set by the connection.xml in APK by using another connection.xml file on the Android device. For other platforms, Kanzi Connect uses the configuration files from the application installation directory.

Kanzi Connect applies the parameters you set in the connection.xml file in this order:

  1. The connection.xml on the device storage in the $SECONDARY_STORAGE/Connect directory

  2. The connection.xml on the device SD card in the $EXTERNAL_STORAGE/Connect directory

  3. The connection.xml in the apk file

For example, to configure on Android a Kanzi Connect application to connect to a Kanzi Connect Server which is running on another device:

  1. Create a connection.xml file where you configure the parameters you want your Kanzi Connect application to use.

    For example, in the connection.xml file set the IP address of the computer which is running Kanzi Connect Server to which you want your application to connect.

    <root>
        <connection_adapter>
            <!-- The name by which a Kanzi Connect server recognizes a client -->
            <name>My Kanzi Connect application</name>
            <!-- The Kanzi Connect server provided by this connection adapter -->
            <server_name>Server</server_name>
            <!-- Connection details, bearer name, and its attributes -->
            <bearer>connect.bearer.tcp</bearer>
            <attribute name="host_ip" value="10.20.30.40"/>
            <attribute name="host_port" value="2002"/>
        </connection_adapter>
    </root>
    
  2. Connect your Android device to your computer and set the connection type to Transfer Files.

    This way you can access the device file system with Windows Explorer.

  3. Copy the connection.xml file to your Android device to the Internal Storage/Connect directory. If the directory does not exist, create it.

    When you run your Kanzi Connect application on your Android device, the application uses the parameters you set in the connection.xml file.

Running a Kanzi Connect application

To run a Kanzi Connect application on an embedded device:

  1. Copy the application binary to the target device:

    • During runtime, the application requires Kanzi Connect libraries. Depending on the integration, Kanzi Connect applications can share libraries. If the platform does not allow this, copy the Kanzi Connect libraries to the same directory where the application binary is.

    • Platform library loader must know the library location. On Windows, the libraries in the application directory are loaded automatically. On most Linux-like platforms, you must add the application directory to the loader path. Kanzi Connect SDK contains an utility <KanziConnectInstallation>/SDK/create_target_device_bundle.sh that collects all the libraries and example binaries for a Kanzi Connect supported embedded platform.

    • On Windows, it is recommended that you keep the Kanzi Connect directory structure created by the installer. However, you can copy and run a Kanzi Connect server on another computer, but you must maintain the relative locations of these configuration directories:

      • <KanziConnectInstallation>/certs

      • <KanziConnectInstallation>/configs

      • <KanziConnectInstallation>/ContentPack

      • <KanziConnectInstallation>/output/win32

      To use the kzb Player, copy all the libraries (*.dll) for the matching kzb Player configuration (<KanziConnectInstallation>/output/win32/GL_vs2015_Release_DLL or <KanziConnectInstallation>/output/win32/GL_vs2015_Debug_DLL) to the KzbPlayer directory.

      To use the kzb Player, the Kanzi Engine plugins and connection.xml must be in the same directory, like any Kanzi application.

    • Using kzb Player for Kanzi Connect applications on embedded platform is not recommended. Kanzi Connect application template on Kanzi Studio contains platform required adjustments for the Kanzi Connect and Kanzi libraries and avoids the need for advanced troubleshooting.

  2. Start the Kanzi Connect Server on your computer or another device in the subsystem.

  3. Start your Kanzi Connect application on the device to which you deployed the application. On Android device you can launch the application using the device application launcher or adb. On other embedded targets use either shell or a start-up script.