Building and 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:
Connect your Android device to your computer.
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 useKANZI_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:
In Kanzi Studio main menu select File > Open Kanzi Command Prompt or open the terminal on Linux.
In the Kanzi Connect SDK directory run the script
build_app.py
.Syntax
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
,GL_vs2019_Release_DLL
andGL_vs2017_Release_DLL
build the application with compiler optimizations enabled. This option builds smaller files than theDebug
option. Use this option for production purposes. The default value isGL_vs2019_Release_DLL
.Debug
,GL_vs2019_Debug_DLL
andGL_vs2017_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.0GL
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:
arm
aarch64
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 andIntegrity OS
builds use static linking in Kanzi Connect applications.Examples
To build the Cluster example application with the Debug configuration for Android Gradle workflow.
To build the IVI example application with the GL_vs2019_Release_DLL configuration for Windows.
To build the HUD example application with the Release configuration for QNX 7.0, using the dynamic libraries.
To build the Android Kanzi Connect server with the Release configuration for the Android gradle with the aarch64 eabi.
To build the Kanzi Connect server with the default (Release) configuration for Windows.
Building Kanzi Connect applications using a Scons script¶
In Kanzi Studio main menu select File > Open Kanzi Command Prompt or open a terminal on Linux.
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.0GL
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.
Integrity OS
build uses static linking in Kanzi Connect applications.Examples
To build an application with the default settings as specified in
config.py
and SConstruct configuration files.To build the Release version of an application with the OpenGL ES 3.0 graphics library.
To build the Debug version of an application with the OpenGL graphics library and dynamic libraries.
Builds the Debug version of an application with the OpenGL ES 2.0 graphics library from the Kanzi Studio project named
MyProject
.Scons builds the Kanzi application source code and binary files in the
<ProjectName>/Application/lib
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:
The
connection.xml
on the device storage in the$SECONDARY_STORAGE/Connect
directoryThe
connection.xml
on the device SD card in the$EXTERNAL_STORAGE/Connect
directoryThe
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:
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"/> <attribute name="alt-addresses" value=""/> <attribute name="connection_timeout" value="5000"/> </connection_adapter> </root>
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.
Copy the
connection.xml
file to your Android device to theInternal 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:
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>/SDK/lib/win64
To use the kzb Player, copy all the libraries (
*.dll
) for the matching kzb Player configuration (<KanziConnectInstallation>/SDK/lib/win64/GL_vs2019_Release_DLL
or<KanziConnectInstallation>/SDK/lib/win64/GL_vs2019_Debug_DLL
) to theKzbPlayer
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.
Start the Kanzi Connect Server on your computer or another device in the subsystem.
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.