LifeLine SDK
LifeLine SDK
4.1.2
LenovoEMC Confidential
LenovoEMC believes the information in this publication is accurate as of its publication date. The information is subject to change without notice. WARNING: THE INFORMATION CONTAINED HEREIN HAS NO WARRANTY. LENOVO EMC, LTD. AND THEIR AFFILIATES MAKE NO WARRANTIES EXPRESS OR IMPLIED CONCERNING ANY INFORMATION PROVIDED HEREIN. THIS DOCUMENT AND ALL OF ITS CONTENTS ARE PROVIDED ON AN AS IS BASIS. THE USER ASSUMES ANY RISK OF LOSS INCLUDING ANY LOSS OF DATA, AND AGREES TO WAIVE ANY CLAIM FOR DAMAGES ASSOCIATED WITH THE INFORMATION HEREIN. PLEASE DO NOT USE THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN IF YOU DO NOT AGREE. BY PROCEEDING TO USE THIS DOCUMENT OR ANY INFORMATION HEREIN, YOU AGREE TO WAIVE ANY AND ALL CLAIMS FOR DAMAGES, INCLUDING DIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, AND LOST PROFIT DAMAGES.
Use, copying, and distribution of any LenovoEMC software described in this publication requires an applicable software license.
Copyright 2013 LenovoEMC, Ltd. All rights reserved. LenovoEMC and LifeLine are trademarks of LenovoEMC, Ltd. in the United States, other countries, or both. Lenovo and the Lenovo logo are registered trademarks of Lenovo in the United States, other countries, or both. The EMC logo is a registered trademark of EMC Corporation in the United States and/or other countries. Certain other product names, brand names, and company names may be trademarks or designations of their respective owners.
3/11/13 7/31/13
4.0.2 4.1.2
Updates Updates to sections 2, 3, 6, 10, 12.9, 13.5, 14, 15. Added sections 12.13, 12.14, 12.15, 12.16
Page 2 of 60
4.1.2
Table of Contents
1 1.1 2 2.1 2.2 2.3 2.3.1 2.3.2 3 3.1 3.2 3.3 3.4 4 5 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 6 6.1 6.2 6.2.1 6.2.2 6.3 6.3.1 6.4 7 8 Preface................................................................................................................................................... 7 Intended Audience and Development Prerequisites ....................................................................... 7 Introduction .......................................................................................................................................... 7 SDK Terminology ............................................................................................................................ 7 Supported Architectures.................................................................................................................. 8 LifeLine SDK Features .................................................................................................................... 8 Applications .............................................................................................................................. 9 Libraries ................................................................................................................................... 9
Getting Started ..................................................................................................................................... 9 LifeLine SDK System Requirements ............................................................................................. 10 Installing the LifeLine SDK ............................................................................................................ 10 Installed Components ................................................................................................................... 11 Checking Your LifeLine SDK Installation ...................................................................................... 11 LifeLine API Reference ...................................................................................................................... 11 Application Creation Overview ......................................................................................................... 12 Your Applications with LifeLine Applications................................................................................. 12 Use the o2 Tool for an Application Template ................................................................................ 12 Write Your Code ............................................................................................................................ 12 Design a User Interface for Your Application ................................................................................ 12 Build Your Application ................................................................................................................... 12 Create an Application Set ............................................................................................................. 13 Build Your Application Set ............................................................................................................ 13 Test Your Application .................................................................................................................... 13 Creating a LifeLine Application ........................................................................................................ 13 Using the o2 Tool .......................................................................................................................... 13 Modifying the Application.xml File ................................................................................................. 13 Application File Example ....................................................................................................... 14 Application Parameters .......................................................................................................... 15 Supported categories .................................................................................................................... 18 Setup category ....................................................................................................................... 19 Interaction between executable file and Application Manager...................................................... 19 Writing Your Code .............................................................................................................................. 20 Designing a User Interface ................................................................................................................ 20
Page 3 of 60
4.1.2
2013 LenovoEMC, Ltd. 8.1.1 8.1.2 8.1.3 9 10 10.1 10.2 10.3 11 11.1 11.2 12 12.1 12.1.1 12.1.2 12.2 12.3 12.3.1 12.3.2 12.3.3 12.3.4 12.3.5 12.4 12.5 12.6 12.6.1 12.6.2 12.6.3 12.6.4 12.7 12.8 12.8.1 12.8.2 12.9 12.10 12.11 12.12
Building Your Application ................................................................................................................. 22 Creating an Application Set ........................................................................................................... 22 Modifying the <application set id>.xml File ............................................................................... 23 Application Set Parameters ....................................................................................................... 23 Building Your Application Set .................................................................................................... 24 Testing Your Applications ............................................................................................................. 24 Setting up the LifeLine VM ........................................................................................................ 25 Login Credentials with Security Enabled ................................................................................... 25 Designing More Advanced Applications ...................................................................................... 25 Interprocess Communication Between LifeLine and SDK Applications .................................... 26 Third-party Application functions ........................................................................................... 26 Library for the Inter Process Communication (IPC) Mechanism ........................................... 26 Events ........................................................................................................................................ 29 Redirection APIs ........................................................................................................................ 30 Selective Redirection ............................................................................................................. 31 Global Redirection ................................................................................................................. 31 Stopping Redirection ............................................................................................................. 31 Homepage Redirection .......................................................................................................... 31 Redirection sample ................................................................................................................ 32 Custom home page ................................................................................................................... 32 Linux Kernel Module Development ........................................................................................... 32 Exposing New REST APIs ........................................................................................................ 32 sdkapi.xml definition............................................................................................................... 32 SDK API parameters.............................................................................................................. 34 Registering DBus Callbacks .................................................................................................. 35 Incoming data ........................................................................................................................ 35 Registering callbacks for LifeLine REST APIs .......................................................................... 36 Deferred Schedule..................................................................................................................... 37 Registering a Schedule .......................................................................................................... 37 Deregistering a Schedule ...................................................................................................... 37 Custom apache module ............................................................................................................ 38 Calling LifeLine API from the backend ...................................................................................... 39 Web server proxy configuration ................................................................................................. 39 Email notifications...................................................................................................................... 40
Page 4 of 60
4.1.2
2013 LenovoEMC, Ltd. 12.13 12.13.1 12.13.2 12.13.3 12.14 12.15 12.16 13 13.1 13.2 13.3 13.4 13.5 13.6 13.7 14 14.1 14.1.1 14.2 14.2.1 14.2.2 14.2.3 14.3 14.3.1 15 15.1 15.2 15.3 16 17 18 19 20 20.1 20.2 20.3 20.3.1
Video output support ................................................................................................................. 40 Compiling SDK applications with QT support .................................................................... 41 API interaction .................................................................................................................... 41 Additional configurations .................................................................................................... 42 User Visible Logs....................................................................................................................... 42 Storing Application Data ............................................................................................................ 42 Custom validation during installation ......................................................................................... 43 Application Best Practices ............................................................................................................ 43 Verify a Service or Feature Is Running Before Using It ............................................................ 43 No Share Creation Until a User Launches an Application ........................................................ 43 Control Running State of the Application on the Applications Home Page .............................. 44 Check Firmware Version for Compatibility ................................................................................ 44 Store Application Data and User Metadata in the ApplicationData Share ................................ 44 When to Use Callbacks for LifeLine APIs ................................................................................. 45 Combining Configuration Parameters for the Applications Executable .................................... 45 Upgrading an Application .............................................................................................................. 46 Upgrade Info XML File .............................................................................................................. 46 Parameter Explanations ........................................................................................................ 46 Manual Upgrade ........................................................................................................................ 49 Including the Upgrade Information File in the TGZ File ......................................................... 49 Upgrading through the UI ...................................................................................................... 49 Upgrade through the REST APIs ........................................................................................... 50 Automatic Upgrade .................................................................................................................... 51 Automatic Upgrade Procedure .............................................................................................. 51 Migration from Previous Versions of the LifeLine SDK .............................................................. 52 Migrating to Version 4.1 from Any Version Before 4.0 .............................................................. 53 Migrating to Version 4.1 from Any Version Before 3.2 .............................................................. 54 Migrating to version 4.1 from versions 3.2 and 3.3 ................................................................... 55 Deleting Applications during an Upgrade .................................................................................... 55 Debugging Applications ................................................................................................................ 55 Recommended Testing Tools ....................................................................................................... 55 Getting Help .................................................................................................................................... 55 Appendix A Sample Code .............................................................................................................. 56 REST and XMLRPC Examples ................................................................................................. 56 REST Call with No Parameters ................................................................................................. 56 REST Call with Parameters ....................................................................................................... 57 Shares API ............................................................................................................................. 57
Page 5 of 60
4.1.2
2013 LenovoEMC, Ltd. 20.3.2 20.3.3 20.4 20.5 20.6 20.7 20.8 20.9 20.10 20.11 21 21.1 22
SecurityEnable API ................................................................................................................ 58 UserCreate API ...................................................................................................................... 58 REST Call with Struct as a Parameter ...................................................................................... 58 Error Information........................................................................................................................ 58 To Call Methods Using XML-RPC ............................................................................................. 58 Example XML-RPC call with No Parameters ............................................................................ 59 Example XML-RPC call with Parameters .................................................................................. 59 Example XML-RPC call with Struct as a Parameter ................................................................. 59 Error Information........................................................................................................................ 59 Sample Applications .................................................................................................................. 59 Appendix B SDK Utilities ............................................................................................................... 60 SDK Application Utility Program ................................................................................................ 60 Appendix C Installing Partners Applications at Manufacturing ................................................ 60
Page 6 of 60
4.1.2
1 Preface
Welcome to the Software Developer's Guide for LifeLine. In this guide, you will find the information you need to use the Software Development Kit (SDK) that LifeLine provides. This guide contains information on the tools and APIs provided to help you create applications for LifeLine.
1.1
2 Introduction
The LifeLine SDK is a software development kit that contains a collection of tools, application programming interfaces (APIs), sample applications, and documentation. It is used to build custom applications that access LifeLine functionality.
2.1
SDK Terminology
There are several terms you should know to become familiar with the LifeLine SDK. LifeLine: The LenovoEMC Original Equipment Manufacturer (OEM) storage platform software used in LenovoEMC devices. o2: (O2) Oxygen SDK command line utility. Application Set: A single file that contains one or more applications to be loaded onto a LenovoEMC device running LifeLine.
Page 7 of 60
4.1.2
2.2
Supported Architectures
The LifeLine SDK supports various computer processor architectures, and each can be used for compiling applications so they execute optimally on different LifeLine devices.
b4b
px4-400d px4-400r
b2a x86_64-ix
2.3
Page 8 of 60
4.1.2
2.3.1 Applications
The LifeLine SDK includes example applications written in C. These applications are available in the $LLSDK_HOME/samples/ directory.
2.3.2 Libraries
The LifeLine SDK includes a set of open source libraries that are useful in application development, and SDK developers have an open license to use these libraries. Some of the core libraries are listed below: DBus (Desktop Bus) DBus is a daemon running in the system that controls application communication. All applications that need to communicate with each other on DBus connect to the daemon first. GLib GLib is a general utility library used as the lowest layer of the GTK+ graphical user interface software stack. GLib attempts to abstract most of the operating systems functions allowing GTK+ to run on Linux, Mac (using XWindows), and Windows. SQLite SQLite is a relational database engine available to all applications written for LifeLine.
3 Getting Started
The first step towards using the LifeLine SDK is to install it. The LifeLine SDK is available for download from http://developer.lifelineapps.com. You must first register as a user and create an account before you can access the download site. The LifeLine SDK is composed of seven separate packages, that can be downloaded according to your specific needs: LifeLine-SDK-<version>.tar.bz2 The base package for the SDK, containing all the scripts (o2 tool, build scripts, SDK installation script), SDK sample applications, SDK documentation, REST API documentation and licenses. This package is mandatory to be able to write and compile your own SDK applications. LifeLine-SDK-ARM-<version>.tar.bz2 - package containing the platform-specific versions of the libraries and header files used by the LifeLine SDK for ARM-based devices. LifeLine-SDK-ARM-Kernel-<version>.tar.bz2 - package containing the kernel source files for ARM-based devices. LifeLine-SDK-Intel-<version>.tar.bz2 - package containing the platform-specific versions of the libraries and header files used by the LifeLine SDK for Intel-based devices. LifeLine-SDK-Intel-Kernel-<version>.tar.bz2 - package containing the kernel source files for Intel-based devices. LifeLine-SDK-Toolchain-<version>.tar.bz2 package containing the toolchains used by the LifeLine SDK for all device models. This package is mandatory to be able to write and compile your own SDK applications. LifeLine-SDK-VM-<version>.tar.bz2 package containing the latest LifeLine virtual machine and its platform-specific libraries, header files and kernel source files used by the LifeLine SDK. This package is only needed to compile and test SDK applications without using real LifeLine devices. After downloading the required packages of the LifeLine SDK, you install them on your development machine. There is a dependency tree among these packages. During the installation procedure, the LifeLine SDK will validate that the versions of the downloaded packages are all compatible. If an update is released for one or more of these packages, you may download only the necessary packages and run the installation script again, passing only the new packages, to install them and verify that theyre still compatible with the packages that were not updated.
Page 9 of 60
4.1.2
When any application is built using the LifeLine SDK, these dependencies are also validated to make sure that the generated installation package is actually compatible with the target version of the LifeLine firmware.
3.1
3.2
Page 10 of 60
4.1.2
3.3
Installed Components
After installing the LifeLine SDK, the following components are available: Compiler toolchains Libraries and header files for each of the supported architectures Application management scripts, such as o2. Sample applications Documentation
3.4
Page 11 of 60
4.1.2
5.1
5.2
5.3
5.4
5.5
Page 12 of 60
4.1.2
5.6
5.7
5.8
6.1
6.2
Page 13 of 60
4.1.2
Page 14 of 60
4.1.2
<msgstr>Um das Gert zurckzusetzen, drcken Sie die kleine vertiefte Taste auf der Rckseite.</msgstr> </Locale> <Locale Id="es"> <msgstr>Para restablecer el dispositivo, presione el pequeo botn empotrado que se encuentra en la parte posterior.</msgstr> </Locale> </Text> <Text msgid="General Error!" lognumber=17> <Locale Id="de"> <msgstr>Allgemeiner Fehler!</msgstr> </Locale> <Locale Id="es"> <msgstr>Error general!</msgstr> </Locale> </Text> </Localization> </application>
Definition Localization information. The value defined here points to the attributes that are going to be localized, using the strings defined in the Localization element. Any function that an application can call during the authentication process. This is an optional parameter and is called by LifeLine over DBus. If 1 then cgibinDir directives are created in the Apache.conf file so that it can be accessed by the web. The application access URL will be <http://<ip-address>/apps/<vendor>/<app-id>/cgibin/ If 1, the Apache server is configured to decode the characters in the "QUERY_STRING" part of the URLs for incoming CGI requests, before setting up the environment variables for the request and invoking the CGI script. A 50-pixel x 50-pixel image file that must be
<application/authenticateFunc>
<application/cgibinDir>
<application/decodeUrlParameters>
<application/icon>
Page 15 of 60
4.1.2
CONFIDENTIAL AND PROPRIETARY provided so it appears in the UI. The path must be relative to the applications www directory.
<application/smallicon>
A 32-pixel x 32-pixel image file that must be provided so it appears in the UI. The path must be relative to the applications www directory. A unique identifier for an application, which supports alpha characters only. No two applications can have the same ID within the same vendor. A localized space-separated list of keywords that is used in the feature search. If no keyword is specified, the search never finds this application. The application name. It can be localized. Any function that an application can call during the initial setup sequence. This is an optional parameter and is called by LifeLine over DBus. Application vendor name. This name is also in the application set configuration file. The application version. If 1, then www directives are created in the Apache.conf file so that it can be accessed by the UI. The application access URL is <http://<ip-address>/apps/<vendor>/<app-id>/ If 1, then all html pages in the applications www directory will pass through the LifeLine Parser when they are accessed by the UI. For more information on the LifeLine parser, refer to sections 8.1.2 and 8.1.3. Defines whether the icon for the application is visible in the LifeLine UI. If 1, no icon is displayed for this application. Defines whether the application contains a custom Apache module. If 1, the custom module definition must be present in the <webserver/custommodule> tag. Defines whether the application requires a proxy configuration to be made to redirect all incoming requests to a custom web server If 1, the proxy configuration parameters must be present in the <webserver/proxy> tag.
<application/id>
<application/keywords>
<application/displayName> <application/setupFunc>
<application/lifelineParser>
<application/hidden>
<application/custommodule>
<application/proxy>
<application/applicationdata>
Defines whether the application requires a folder to be created in the ApplicationData share to store its application data. If 1, the path to the new folder will be passed on as the second argument to the executable of the application.
<category/id>
The category in which the application is a member. Multiple categories are allowed, and the application
Page 16 of 60
4.1.2
CONFIDENTIAL AND PROPRIETARY icon is available in the Web UI for each category specified. Supported id values are listed in Section 6.3.
<description/_gettext_>
Localization information for description. The value defined here points to the attributes that are going to be localized, using the strings defined in the Localization element. Description of the application. Displayed like ToolTip text. A page that opens when the application icon is clicked. The path must be relative to the applications www directory. This page always opens in a new browser window.
<description/Text> <uri/Text>
<executable/command>
An executable command that is started by the LifeLine Application Manager according to the additional configuration values. Do not daemonize this executable file. Refer to section 6.4 for details on the interaction of the LifeLine Application Manager with the executable file.
Schedules the executable to run the specified number of days. Identifies the maximum memory allowed for this executable. Schedules the executable to run the specified number of minutes. Identifies if the executable is restarted after reboot. If set to 1, the executable runs only once. Otherwise, the executable is called again soon after it ends. If set to 1, the executable will run for the amount of time specified by the values for the days and minutes parameters. Set the priority that is used to run this executable, according to the usual process priority settings used in Unix-like systems. Used to configure the entry for the application in the "Setup" page. This element is only required when the application is added to the "setup" category. This parameter specifies the position of the application icon on the Setup page. A JavaScript file that is called when the setup page is loaded. The path must be relative to the applications www directory. For example: scripts/file.js
<executable/scheduled>
<executable/nice>
<setup>
<setup/sequence> <setup/uri/Text>
Page 17 of 60
4.1.2
Refer to section 6.3.1 for details about the required contents of this file. <webserver/custommodule/path> A custom apache module used to handle incoming HTTP requests directed at the applications URLs. The path must be relative to the applications base directory. Refer to section 12.9 for more details about this feature. <webserver/custommodule/module> <webserver/custommodule/handler> <webserver/custommodule/www> The name of the external variable of type module defined in the source code of the custom module. The name of the actual handler declared in the .so file. Specifies whether the custom module should handle requests directed at the URLs of the applications www directory. Specifies whether the custom module should handle requests directed at the URLs of the applications cgi-bin directory. The location to be used for the proxy configuration. Refer to section 12.11 for details about this feature <webserver/proxy/http> <webserver/proxy/https> <Localization> Specifies which port number should be used for the HTTP traffic that is redirected by the proxy. Specifies which port number should be used for the HTTPS traffic that is redirected by the proxy. Used to configure translatable strings that can be used for translating any user-visible text for the application, such as the "description" and "keywords" attributes from the application.xml file or any text in the html pages of the application. The original text that will be translated. All occurrences of the text in the UI must be an exact match with this string. The log number of a message that will be used as a user-visible log in the Event Log. This number must be unique for each vendor. The language code for the translated text. Can be one of the values defined in section 8.1.1. The actual translated text.
<webserver/custommodule/cgibin>
<webserver/proxy/location>
<Localization/Text/msgid>
<Localization/Text/lognumber
<Localization/Text/Locale/Id> <Localization/Text/Locale/msgstr>
6.3
Supported categories
The supported categories for displaying your application in the LifeLine Web UI are common, cloud, system, backup, media, storage, network, surveillance, and setup. Your application can be included in as many categories as suitable, but it should be included in at least one specific category other than "common".
Page 18 of 60
4.1.2
$("#<vendor_id>_<application_id>setup .status").text(<status>); E.g: $(#companyXYZ_sampleAppIdentitysetup .status).text(Sample application is installed.) Since this function is invoked by LifeLine's setup page, it is not necessary to include the jQuery library in your application just for this.
<vendor_id>_<application_id>launch(): This function must open the application's configuration page in a new window. Since this function is invoked by LifeLine's setup page, it is necessary to include the relative path to the html page, such as:
../apps/<vendor>/<app-id>/<pagename>.html
Refer to the "setuppageapp" sample SDK application for examples of how to perform these steps.
6.4
Independent of the behavior imposed by the two flags above, an executable file must be running to handle incoming calls to any of the backend functions registered for the REST API exposed by the SDK application. To help with that, whenever a REST API is called, the executable is automatically started by the Application Manager (in case it is not running already) and, shortly after that, the respective registered function is called via Dbus.
Page 19 of 60
4.1.2
Because of that, whenever an executable is started by the Application Manager, it must remain running at least for a few seconds to allow it to receive the incoming Dbus calls. It is not necessary, however, to keep the executable locked in a running state forever just to handle incoming Dbus calls. This is usually done using an infinite loop and should be avoided. Refer to the SDK API Test sdk sample for a simple keep-alive mechanism that allows the executable to receive incoming Dbus calls without having to keep it locked in an infinite loop. The restartOnReboot and runOnce parameters are enabled by default, which allows the Application Manager to start your application executable automatically when your storage device starts. When the executable starts, it runs initialization steps that allow your SDK application to work. Those initialization steps may include: Receive the path to the automatically created share to store application data Register backend functions for the REST APIs exposed by the SDK application (refer to section 12.6 for details) Register APIs to be notified of LifeLine events (refer to section 12.2 for details) Register callbacks for LifeLine APIs (refer to section 12.7 for details)
Enabling restartOnReboot and disabling runOnce is not recommended, particularly if the executable file has a very short life cycle. In this case, the executable completes quickly and is continuously restarted by the Application Manager when the storage device restarts. This can consume system resources and affect system operating performance. It should be avoided.
CGI scripts that should be executed by the web server to dynamically generate UI pages must be placed inside the applications cgi-bin directory, named cgi-bin and located inside the application's www directory.
Page 20 of 60
4.1.2
Page 21 of 60
4.1.2
The localization routines from the LifeLine Parser present the same behavior of the gettext library, including the translation of an empty string into the translation header information. Because of this, SDK applications must take the necessary measures to ensure that their UI pages never request the translation of an empty string. Doing so would result in a large amount of text being returned and displayed in the place of the expected translated strings. A complete description for all available functions is in the "LifeLine Parser Guide". These functions are executed on the server side, before the Apache server returns the requested html page to the client. To invoke any of these functions, they must be included anywhere in the html or JavaScript code of the pages, preceded by the "@@" tag. For example: @@_x("Text to translate"): Translate the quoted text, using LifeLine's native database of localized strings, as well as any localized strings defined in the application.xml file. @@_api("Feature", 52): Get the JSON response from the "Feature" REST API, for the feature with id 52.
Page 22 of 60
4.1.2
You will find the following files in the application set directory: <app set id>.xml: This file defines constant values about the application set, its vendor, and the applications contained in the set. The application set can contain one or more applications. The file is used to create the final tgz file that can be installed on the LifeLine devices. <app set id>_upgrade.xml: This file defines additional parameters for the installation and upgrade of the application set and its applications. The file is always included in the TGZ file, to be used to upgrade previously installed versions of the application set on the LifeLine devices or install it from scratch. For more information, refer to Upgrade Info XML File. Makefile: The utility that builds your SDK application set.
<vendor/name>
Application Set vendor name. This should be the same name as the one in the Application configuration file. Description for the vendor. This is not displayed in the LifeLine UI. The company that holds the application set copyright. A unique identifier for an application set that supports alpha characters only. This is not displayed to the user.
Page 23 of 60
4.1.2
This was formerly the "name" attribute. The name attribute is retained for backward compatibility but will be phased out in two releases. <applicationSet/displayName> Application Set name. This is displayed in the LifeLine UI on the list of installed application sets in the Application Manager page. This display name can be localized. Application Set version. This is displayed in the LifeLine UI in the list of installed application sets on the Application Manager page. Flag used to prevent the application set from being uninstalled. If this flag is set, once the application set is installed, it cannot be uninstalled using the LifeLine APIs. Application Set description. This is not displayed in the LifeLine UI. URL of the remote XML file that contains information about the latest update that is available for the application set. ID of one of the applications in the application set. This field should not be edited manually. Flag used to delete an application during the application set upgrade process. For more information, refer to section 16.
<applicationSet/version>
<applicationSet/blockuninstall>
<applicationSet>/<description> <upgradeInfo>
<application/id> <application/delete>
Page 24 of 60
4.1.2
Page 25 of 60
4.1.2
Page 26 of 60
4.1.2
2013 LenovoEMC, Ltd. CPStatus_t cpIpcCleanup(); void cpIpcSetThreadUser(const char *user); void cpIpcSetThreadLanguage(const char *lang);
CPIpcCallback_t is defined as follows: typedef void (*CPIpcCallback_t) (const char *contextin, const char *xmlin, char **xmlout, CPResult_t *result); This means the callback functions receive two strings (contextin and xmlin) and return one string (xmlout) and a result. The contextin parameter is an XML string containing context information about the IPC call. This XML is in the following format: <context><session>session_id</session><language>language</language></context> When the incoming XML-RPC data is originated by a REST API call, the session_id string contains the id of the current Apache session associated with the REST API call. This session id can be used in the form of a cookie to issue additional REST API calls to LifeLine without the need to perform a login. The session_id string may be empty if there is no Apache session associated with the IPC call. The language string is an identifier of the language associated with the IPC call that may be used for internationalization purposes. The xmlin parameter follows the XML-RPC specification, as specified by http://www.xmlrpc.com. The xmlout output value must also be in XML-RPC format. The result output value must contain a status code. If the status code is not ME_OK, a description must also be returned. The possible values for the status code can be found in the CP/Result.h file. After registering a function and starting the listener, any IPC call can trigger the specified callback function. 12.1.2.1 Exposed Functions CPStatus_t cpIpcInit(); This function initializes the CPipc library and must be called once before calling any of the other library functions. CPStatus_t cpIpcCleanup(); This function performs a cleanup on the CPipc library, removing all registered callbacks. It is the counterpart to cpIpcInit() and should be called once after the application is done using the CPipc library. Applications are responsible for removing all their registered callbacks before being uninstalled from the device. This can be achieved by using a callback for the SoftwareUninstall API, according to the details in section 12.7. CPStatus_t cpIpcRegisterCallback(const char *methodName, CPIpcCallback_t callback); This function registers an entry point into the SDK application that may be called by LifeLine or by other SDK applications, and it must always be called by the same executable as specified in the executable tag of the application.xml file. The first parameter, methodName, specifies the name of the API that is exposed to external processes. The second parameter, callback, is a pointer to a callback inside the SDK application. CPStatus_t cpIpcStartListener(const char *name);
Page 27 of 60
4.1.2
This function starts a new thread that listens for IPC calls. When this thread receives a call to any of the registered entry points, it calls the associated callback function. The name parameter is used to uniquely identify the SDK application to the IPC mechanism. Therefore, it must be composed of both the vendor name and the application id, in the form: <vendor>_<app_id>. For example, companyXYZ_sampleAppIdentity. CPStatus_t cpIpcStopListener(); This function stops the IPC listener thread. All the CPipc library functions return a CPStatus_t result. On success, ME_OK is returned. Any other value means an error occurred. void cpIpcSetThreadUser(const char *user); This function associates the current thread with any existing LifeLine user, regardless if it is an administrator user or not. After this is done, the current thread inherits all access permissions that have been configured for that user in LifeLine, with respect to subsequent calls to LifeLine APIs done via the CPipc library. This feature is particularly useful when calling LifeLine APIs that require administrator credentials. In this case, the current thread must be associated with an existing LifeLine administrator user. void cpIpcSetThreadLanguage(const char *lang); Similar to the previous function, this function changes the language associated with the current thread. This causes LifeLine to return localized texts and error messages when calling LifeLine APIs via the CPipc library. In addition, additional regional settings are also applied to the values returned by LifeLine, such as right-to-left text, number format, date format, etc. The language values supported by this feature are listed in section 8.1.1Error! Reference source not found.. 12.1.2.1.1 IPC Samples There are two samples using IPC: ipctest and ipccallback. These are contained in the sdksamples application set. To run these applications: 1. Install the application set 2. Run the desired sample: /opt/apps/vendor/sample 3. Call the desired method using the /usr/local/cp-utils/cp-sdkipc utility 12.1.2.1.2 ipctest ipctest is a simple application containing two functions, printTime and quit. These functions are registered. The function printTime writes the devices current date/time to the console, if ipctest was executed manually. The function quit stops the application. A user can test these functions through the test utility program cp-sdkipc, using the following commands: /usr/local/cp-utils/cp-sdkipc call ipctest lenovoemc "<methodCall><methodName>printTime</methodName><params/></methodCall>" /usr/local/cp-utils/cp-sdkipc call ipctest lenovoemc "<methodCall><methodName>quit</methodName><params/></methodCall>" Where the first command outputs the date and time, and the other command quits the application.
12.1.2.1.2.1
Troubleshooting
Page 28 of 60
4.1.2
Problem: I cannot see the current time when I call the printTime callback. Solution: To see the output, ipctest must be run interactively from a console. This is necessary because the current time is displayed on the terminal where ipctest is running and not on the terminal where cpsdkipc was invoked. One way to accomplish that is to first stop the running ipctest and then start it again manually, as illustrated by the following commands: /usr/local/cp-utils/cp-appmd stop ipctest cd /opt/apps/lenovoemc/ipctest ./ipctest Now, on a different terminal, invoke the printTime callback with cp-sdkipc and go back to the terminal where ipctest is running to see the output. Problem: Unable to retrieve information. /usr/local/cp-utils/cp-sdkipc call ipctest lenovoemc "<methodCall><methodName>printTime</methodName><params/></methodCall>" Error: Unable to retrieve the requested information. Solution: Be sure your application is running before calling the method. If your application is running, check for the APPID value in the main.c file. If your application was copied from another file, this #define must be updated as well. 12.1.2.1.3 ipccallback This application shows how to create functions that are triggered from LifeLine when special events occur. This is made by registering three callback functions: sampleSetupFunc sampleAuthenticateFunc
Each one has its corresponding function defined in the application configuration file. Note that the value set in this xml attribute must be an exact match of the function name used as a callback. 12.1.2.2 Common Build Errors Be sure to have CPipc in your Makefile APP_LDFLAGS += -lCPipc-2 -lsoup-2.4 CFLAGS += -I$(ARCH_DIR)/usr/include/libsoup-2.4 CFLAGS += -I$(ARCH_DIR)/usr/include/CP-2 The o2 create script does not enable the CPipc library by default in the makefile it creates, but it includes the above line commented out. You must uncomment it to enable the CPipc library.
12.2 Events
There are currently two ways for SDK applications to interact with LifeLine events: Applications can register for events coming from LifeLine using the CallbackEventRegister REST API. The application must expose a REST API that is called when the registered event is broadcasted by LifeLine, e.g.:
http://<device_ip>/cp/CallbackEventRegister?v=2&id=sharedelete&function=companyXYZ_SampleAppEv entHandler
Page 29 of 60
4.1.2
To stop being notified about specific events, the SDK application must make a similar call to the CallbackEventDeregister API, e.g.: http://<device_ip>/cp/CallbackEventDeregister?v=2&id=sharedelete&function=companyXYZ_SampleApp EventHandler For details about exposing new APIs, refer to section 12.6. Applications are responsible for removing all their registered callbacks before being uninstalled from the device. This can be achieved with the use of a callback for the SoftwareUninstall API, according to the details in section 12.7 Applications can generate events that go into LifeLine using the "EventSend" REST API. These events are propagated internally to all LifeLine native applications and also broadcasted over DBus as signals and automatically forwarded to registered event handlers.
Note: If your application interacts with LifeLine events, you should be aware that events are subject to change from one release of LifeLine to another and this may prevent your application from interacting with events in future releases. There is no guarantee of backward compatibility.
12.2.1.1 Event Samples There is one sample using LifeLine events: deferredevent. This is contained in the sdksamples application set. To run this application: 1. Install the application set 2. Access the UI page of the application: Deferred Event Sample on the All Features page. DeferredEvent is a simple application that monitors LifeLine events broadcasted through its registered APIs. Output from this process is written to the system log on /var/log/messages. A user can test the monitoring of LifeLine events by changing which events are monitored by the application using its UI page and forcing the device to broadcast these events to see what is written to the system log.
Page 30 of 60
4.1.2
Page 31 of 60
4.1.2
Page 32 of 60
4.1.2
<?xml version="1.0" encoding="utf-8"?> <APIDoc> <Subsection vendor="companyXYZ" app="sampleAppIdentity"> <Struct Tag="api_three_info"> <Title>SDK API Three input structure</Title> <Param Tag="text" Type="string"/> <Param Tag="number" Type="i4"/> </Struct> <Struct Tag="api_four_info"> <Title>SDK API Four output structure</Title> <Param Tag="text" Type="string"/> <Param Tag="number" Type="i4"/> </Struct> <Function Id="SDKApiOne"> <Description>Test SDK API one</Description> <Args> <Param Tag="text" Type="string" Optional="1"/> <Param Tag="number" Type="i4" Optional="1"/> </Args> </Function> <Function Id="SDKApiTwo"> <Description>Test SDK API two</Description> <Return Type="string"/> </Function> <Function Id="SDKApiThree"> <Description>Test SDK API three</Description> <Args> <Param Tag="input" Type="struct"> <Struct Reference="api_three_info"/> </Param> </Args> </Function> <Function Id="SDKApiFour"> <Description>Test SDK API four</Description> <Return Type="struct"> <Struct Reference="api_four_info"/>
Page 33 of 60
4.1.2
SDK API Parameter <Subsection/vendor> <Subsection/app> <Struct> <Struct/Tag> <Struct/Title> <Struct/Reference> <Param> <Param/Tag> <Param/Type>
Definition Vendor name of the application that exposes these APIs. Unique identifier of the application that exposes these APIs. Used to define structures to be referenced by the API definitions, following the XML-RPC format. The unique identifier of the structure. A textual description of the structure, used only for documentation. Used to make reference to a previously defined structure. May be added as the contents of any "Param" or "Return" tag. Used to define a newly named parameter that may be part of a structure or an API definition. The name of the parameter. The XML-RPC type of the parameter. This must be one of: i4, i8, string, boolean, struct, array, base64 and dateTime.iso8601. If the "struct" type is used, a reference to a previously defined "Struct" must be included as a child element. Used to define a new REST API. The unique identifier of the API A textual description of the API, used only for documentation. The array of arguments for the API. This may include any number of "Param" or "Struct" tags. The XML-RPC type of the return. This must be one of: i4, i8, string, boolean, struct, array, base64 and dateTime.iso8601. If the "struct" type is used, a reference to a previously defined "Struct" must be included as a child element.
Page 34 of 60
4.1.2
Page 35 of 60
4.1.2
To register a callback for one of the APIs that support that, the SDK application must add an entry to the sdkCallback.xml file: <Callback Name="SampleAppShareDeleteCheck" Reference="ShareDeleteCheck" /> There is no need to declare a body for the callback function in the XML file, since it is mandatory for the callback function to receive exactly the same parameters as the referenced CallbackDefinition. In addition to the XML definition, the SDK applications executable must register a backend function to handle this callback using the CPipc library, according to the details in section 12.1.2: cpIpcRegisterCallback("lenovoemc_SampleAppShareDeleteCheck", sharedeletecheckcallback);
Page 36 of 60
4.1.2
Finally, to interrupt the execution of the original LifeLine API for any reason, the backend function of a Check callback should simply return the ME_CONFIRM status code, accompanied by a suitable description of the reason why the API cant be processed at that moment. Applications should also use a callback for the SoftwareUninstall API to remove all their registered LifeLine API callbacks, using the cpIpcCleanup function of the CPipc library.
Page 37 of 60
4.1.2
APACHE_CFLAGS = -DLINUX=2 \ -D_GNU_SOURCE \ -D_LARGEFILE64_SOURCE \ -D_REENTRANT \ -I$(LLSDK_HOME)/$(arch)/usr/local/apache/include \ -L$(LLSDK_HOME)/$(arch)/usr/local/apache/lib Uncomment the GCC compilation command:
mkdir -p modules/$(target) $(CC) <module .c source file> -fPIC -shared -o modules/$(target)/<output .so library> $(APACHE_CFLAGS) $(CFLAGS) cp -rf modules/$(target)/<output .so library> $(PKG_DIR) The following values should be configured in the application.xml file: application/custommodule: This flag enables the custom apache module feature. webserver/custommodule/path: The path to the .so file. The path must be relative to the applications base directory. This is the path used in the LoadModule directive in the apache configuration file. webserver/custommodule/module: This is the name of the external variable of type module defined in the source code of the custom module, which is also listed as the Module Identifier in the module documentation. This is the name of the symbol used in the LoadModule directive. webserver/custommodule/handler: The name of the actual handler declared in the .so file. This is the value used in the Directory/SetHandler directive in the apache configuration file. webserver/custommodule/www: This flag specifies whether the custom module should handle requests directed at the URLs of the applications www directory. This includes all subdirectories of the www directory, except for the cgi-bin directory, which has its own setting, e.g.: http://<device_ip>/apps/companyXYZ/sampleapp/[...] http://<device_ip>/apps/companyXYZ/sampleapp/images/[...] webserver/custommodule/cgibin: This flag specifies whether the custom module should handle requests directed at the URLs of the applications cgi-bin directory. This includes all subdirectories of the www directory, e.g.: http://<device_ip>/apps/companyXYZ/sampleapp/cgi-bin/[...] http://<device_ip>/apps/companyXYZ/sampleapp/cgi-bin/setup/[...] The remaining parameters used in all Directory entries for the application are fixed: Options -Indexes FollowSymlinks MultiViews
Page 38 of 60
4.1.2
2013 LenovoEMC, Ltd. AllowOverride None Order allow, deny Allow from all
Refer to the Custom Apache Module sample SDK application for an example of how to compile and configure the custom apache module.
12.10
The LifeLine SDK allows executable files that run on the backend to use the CPipc library to issue direct calls to LifeLine APIs, just like regular functions, instead of an HTTP library to issue the calls via HTTP. This mechanism makes it much easier for the backend executables to interact with LifeLine, as well as having the advantage of not requiring the caller to parse the JSON responses received through HTTP. To use this feature, the Makefile of the application must link to the CPipc library, as described in section 12.1.2, and the executable file must include the CP/CPapi.h header file: #include <CP/CPapi.h> The header file above includes all the header files required to be able to use this feature. The actual function signatures for all LifeLine APIs are defined in the CP/cpFuncs.h header file. They are usually in the format: CPStatus_t cp<API name>(CPResult_t *res, [input parameters], <type> **ret) Where: CPStatus_t: the result of the API call, indicating success (ME_OK) or failure (any other value) res: a pointer to an allocated structure that holds the detailed result of the API call. If any value other than ME_OK is returned by the function call, the description field of this struct contain s a textual description of the error. [input parameters]: the input parameters required by the API, in the same order as described in the API documentation. ret: the address of a pointer of the type specified in the API documentation. This pointer is modified to reference the return value of the API, which is dynamically allocated by the API function.
These dynamically allocated values must be freed from memory by the caller when they are no longer used. The CP/structfns.h header file exposes some utility functions to free complex structure returned by the LifeLine APIs The CP/ListUtil.h header file exposes some utility functions to work with lists returned by the LifeLine APIs. The CP/cpStructs.h header file exposes functions to free each of the struct types defined by the LifeLine APIs. In case the LifeLine API being called requires the caller to have administrator credentials, you must use the cpIpcSetThreadUser function to associate the current thread with an existing LifeLine administrator user account. Refer to section 12.1.2.1 for details.
12.11
The LifeLine SDK allows SDK applications to start a custom web server to handle specific incoming requests. To selectively redirect incoming request to their own web servers, SDK applications can create their own proxy configuration in the default web server used by LifeLine.
Page 39 of 60
4.1.2
SDK applications choose a custom path under their base URL to be redirected to their custom web server, which must be running on different ports than the default LifeLine web server (80 for HTTP and 443 for HTTPS). No more than one proxy configuration can be created by each SDK application. Each application can determine which type of traffic gets redirected to their custom web server: HTTP, HTTPS, or both; and also which port to use for each type. To use this feature, the SDK application must start its custom web server when necessary, and the following values should be configured in the application.xml file: application/proxy: This flag enables the proxy feature. webserver/proxy/location: The path under the base URL of the SDK application that is redirected to the custom web server. This path must match the exact path that is going to be redirected to the custom web server, including the leading /. For example: /sampleProxy redirects all requests directed at: http://<device_ip>/apps/companyXYZ/sampleapp/sampleProxy/[...] webserver/proxy/http: This is the port on which the custom web server listens for regular HTTP traffic. webserver/proxy/https: This is the port on which the custom web server listens for regular HTTPS traffic.
Refer to the Proxy sample SDK application for an example of how to configure the web server proxy.
12.12
Email notifications
The EmailSend LifeLine API allows SDK applications to easily send notification emails to the email addresses provided by the device administrator on the Email Notification page of the LifeLine Web UI. In case the administrator has not provided a custom SMTP setting, LifeLine uses the default SMTP server, which has a daily limit of 50 emails for each sender IP. SDK applications can override the SMTP settings using the EmailModify LifeLine API to use a custom SMTP server without this limitation. Refer to the REST API documentation for additional details about the APIs.
12.13
The px LifeLine devices allow the user to connect a PC monitor directly to the VGA/HDMI port and a keyboard to any of the USB ports on the back of the device, to operate it without the need of a PC or an Ethernet network. LifeLine provides QT and DirectFB libraries to produce the video output for these ports, and the default video output is the regular LifeLine Web UI running on a stripped-down QT-based web browser. SDK applications can also produce their own video output to be displayed by these ports. LifeLine supports up to 8 different screens to be rendered at the same time, allowing the device to switch between them instantly. A new set of APIs is available to control the behavior of these screens. In order to use this feature, it is recommended to use an application set with at least two applications: The first application is used to produce the actual video output using the QT and DirectFB libraries. This will be referred to as the display application A second application is responsible for using the VGA APIs to register the display application with a specific screen. This will be referred to as the control application
To use multiple screens in the same application set, it is recommended that a separate application is associated with each screen.
Page 40 of 60
4.1.2
12.13.1
The LifeLine SDK provides the QT shared libraries to streamline the compilation of the QT-based binaries for SDK application. The Makefile template used for creating new SDK applications contains some commented-out variable definitions and the $(QT_APP_LOC)/$(QT_APP) target used for compiling the QT binary that produces the actual video output. To use this feature, you must uncomment the following lines, adding the name of the QT project and output binary file to the QT_APP and QT_PRO variables, respectively: ## ## Definitions for compiling QT application ## #QT_APP_LOC=<directory holding source files of the QT binary> #QT_APP=<name of the resulting QT binary file> #QT_PRO=<name of the QT project (.pro) file> #QT_MKSPECS=$(ARCH_DIR)/usr/qt/mkspecs #QT_MAKE=$(ARCH_DIR)/usr/qt/bin/qt-make You must also uncomment the contents of the QT-specific target: ###### Compile QT application #$(QT_APP_LOC)/$(QT_APP): () With this target in place, the regular compilation of the SDK application (make target=<architecture>) will automatically build the QT binary and place it in the root directory of the application. Since the QT binary may require some input parameters to run, it is recommended that a shell script is configured as the executable of the display application. This script will be invoked by the LifeLine application manager in the appropriate moment and should handle the execution of the QT binary with the necessary input parameters, such as: SampleQTApp --dfb:vt-num=8,session=7 qws display directfb Check the Books SDK sample application for an example on how to build the QT binary and invoke it using the shell script.
12.13.2
API interaction
In terms of SDK interaction and compilation, the control application is a regular application that uses the VGA LifeLine REST APIs to register one or more display applications with their respective screens to display video output. While the display applications are being registered, you may choose to mark one of them as active, using the state flag of the API, to cause it to remain visible as the currently active screen. The display applications themselves can switch the currently active screen when needed, or let the control application handle this. The operations described above utilize the following APIs: AppDisplays - Get a list of application displays. This API can be called by the control application to determine which screens are still available to use, to avoid conflicts with previously installed applications. AppDisplayModify Register a display application with a specific screen. This API is used by the control application to associate each display application with their respective screens. After this
Page 41 of 60
4.1.2
API is called, the referenced SDK application will be executed. You may also choose to activate this screen automatically after that. AppDisplaySwitch Switch the currently visible screen. This API may be used by the display application themselves to switch between different features, such as a configuration screen and a status screen, for example.
Check the complete REST API documentation for detailed usage information of these APIs.
12.13.3
Additional configurations
For better synchronization in the initialization of the control and display applications, it is recommended that: The display applications have their executable files configured with restartOnReboot=0, so that they are only invoked by the LifeLine Application Manager once they have been registered with the AppDisplayModify API. The control application has its executable configured with restartOnReboot=1, so that its executed immediately after installation, in order to be able to register the display applications. The control application waits until all display applications have been completely installed before proceeding with the registration procedure. This can be done using the Software API to check for installed applications.
12.14
The ApplicationLog LifeLine API allows SDK applications to add user-visible messages for important events to the list in the Event Log page of the LifeLine Web UI. User visible log messages should be localized and added to application.xml file, as part of the Localization list. These specific text entries must also contain a lognumber that will be displayed on the Event Log page next to the actual log message. In order to avoid conflicts with other text messages, this log number must be unique for each vendor. When SDK applications call the ApplicationLog API, they must provide: Their unique id, which is composed of the vendor id and application id, in the format <vendor>_<application id> A valid log number, associated with one of the text entries in their own application.xml file The level of the log message, such as normal, error or fatal, to indicate the severity of the message
12.15
The LifeLine SDK allows SDK applications to use a common share to store their internal data. An individual folder for each SDK application will be automatically created inside a share called ApplicationData. To use this feature, the value of the application/applicationdata attribute should be set to 1 on the application.xml file. This indicates that this application needs to have its own folder to store application data. The absolute path of the folder is passed as the second argument to the executable file of the application. The ApplicationData share will always be stored on the user partition, inside a volume that was indicated by the administrator of the device. The default volume, that is used before the administrator makes a selection, is the volume with the largest free space. The ApplicationData share will be automatically created when the first application that uses this feature is installed, or when the administrator chooses the volume where to store this share. This share is created without access permission to any user, so its contents wont be deleted or modified accidentally.
Page 42 of 60
4.1.2
Refer to the applicationdata sample SDK application for an example of how to receive the share path and use it to store data into the applications folder.
12.16
The LifeLine SDK allows application sets to define custom validation steps to be executed during their installation. These steps may be used, for example, to check for the presence of necessary resources on the device. They are configured in the <applicationset>_upgrade.xml file, as Script entries, with the following attributes: File: Each of these steps consists of an executable binary file or script that must work independently of its current path. Shell, python and perl scripts are supported. Phase: This attribute defines whether the step is performed before any of the applications in the installation set are installed (Phase = 0) or after all of them have been completely installed (Phase = 1). ApplyMin / TooNew: These values specify the range of LifeLine firmware versions for which the step must be performed. ApplicationSetApplyMin / ApplicationSetTooNew: In case the application set is being upgraded, these values specify the range of versions of the currently installed application set for which the step must be performed.
The steps that are executed before the installation are able to abort the installation if needed. In order to do so, the executable must simply return a non-zero exit code. In case the installation is aborted, a custom error message may also be returned by the SoftwareInstall API and displayed to the user on the LifeLine Web UI. This optional message must be written to the standard output, localized to the current language selected by the user. The current language selection is passed to the executable as the $1 input argument. Refer to the sdksamples sample SDK application set for an example of how to create custom installation steps and how to receive the language argument in the executable files.
Page 43 of 60
4.1.2
13.3 Control Running State of the Application on the Applications Home Page
The home page of an SDK application should clearly inform to the user whether the application is running and enabled. Its important to note that the running state should not be si mply based on the state of the executable element of the application, for several reasons: The application may depend on more than one executable file or any other combination of factors to be considered enabled. The application may still be disabled, even though its executable file is running on the backend, especially when the executable file is used for handling REST API calls. According to section 6.4, the executable file on the backend might still be listening to incoming requests (and the application might still be enabled), even though it is not continuously running.
The home page should also allow users to enable and disable the application when necessary. For debugging purposes, it is possible to use the /manage/applications.html page to check the running state and start/stop the executable element of each individual SDK that is installed on the device.
13.5 Store Application Data and User Metadata in the ApplicationData Share
SDK applications should not store any data in their installation directories, which reside in the system partition, with limited available space. Data should be stored on the user partitions, which can use all the available disk space on the device. This can be easily accomplished using ApplicationData feature described in section 12.15. This creates an individual folder for the application to store all its application data and user metadata in the ApplicationData share, which resides in the user partition. All applications should store their internal data in the ApplicationData share, to benefit from the following points: Having all application data centralized makes it easier to perform a backup of the settings and metadata of all installed applications at once.
Page 44 of 60
4.1.2
Since this share is created without access permission to users, its contents c ant be accidentally deleted or modified. LifeLine prevents this share from being deleted without warning. The application data is not deleted when the application is uninstalled, so the application can easily restore its state in a future installation.
If the administrator of the device moves the ApplicationData share to a different volume, all application data is automatically moved at once.
All of this without having to remain running all the time or being continuously executed by the Application Manager. 2. restartOnReboot=0 and runOnce=1: this combination might be used by applications that perform all their operations through calls to cgi-bin scripts or LifeLine API calls and dont require any of the backend elements described above. 3. restartOnReboot=0 and runOnce=0: this combination is ideal for applications that must perform critical tasks that, once manually started from the UI, must run continuously, and automatically recover from crashes, until they are manually stopped from the UI. 4. restartOnReboot=1 and runOnce=0: this combination is suitable for executables that must be automatically started by the Application Manager and remain continuously running, automatically recovering from eventual crashes. This combination should only be used for executables with a long life cycle that dont need to be restarted often, except for crashes. Using this combination with executables that perform simple tasks and exit quickly (such as the cases described in item 1) is particularly harmful for the device performance, since the Application Manager is continuously busy restarting this executable.
Page 45 of 60
4.1.2
14 Upgrading an Application
SDK applications can be upgraded manually or automatically using an application set package (TGZ file) with a higher version number..
<Version/Version> <copyright>
Page 46 of 60
4.1.2
The Application Set vendor name. This should be the same name as the one in the Application Set configuration file. Flag to indicate whether the installation package is encrypted. The name of the application set installation package. The URL of the remote location containing the application set package. The size of the application set installation package in bytes. The ID of an application that must already be installed on the device in order to apply this upgrade. The version of the specified application that must already be installed on the device in order to apply this upgrade. The name of a file to be executed during the installation or upgrade of the application set. For more information, refer to section 12.16 The moment in which the file is executed. If 0, the file is executed before the installation or upgrade starts. If 1, the file is executed after all applications in the application set have been completely installed or upgraded. The minimum firmware version for which this file is executed. A firmware version that is too new so that the file is not executed. The minimum version of the Application Set that must be installed in the device to execute the file. An application set version that is too new so that the file is not executed.
<Script/Phase>
In the example above, the Id is the identifier for the LenovoEMC ix2 device. The ApplicationSetApplyMin, ApplicationSetTooNew and depends parameters perform dependency checks during an application set upgrade. The ApplicationSetApplyMin parameter ensures that the specified version of the application set is already installed on the device before upgrading. Checking that the specified application set is installed guarantees backward compatibility between the upgrade version and the currently installed version. The ApplicationSetTooNew parameter ensures that the version of the application set that is already installed on the device is not newer than the specified value. This validation may be useful to prevent, among other issues, the downgrade of the application set in the device. The ApplyMin and TooNew parameters perform analogous checks for the firmware version of the device during an application set install or upgrade. These values are also taken into account when the firmware of the device is upgraded. If a Firmware that is equal to or higher than TooNew value is installed, the executables of all applications in the Application Set will no longer be started automatically by the LifeLine application manager. However, LifeLine does not automatically hide the icons for the unsupported applications nor does it prevent users from trying to interact with them. It is up to the applications to prevent further user interaction if the current firmware version is not supported. The depends parameter checks for application-level dependencies and verifies that the exact version of an application is available on the device. The application can be part of any installed application set. This
Page 47 of 60
4.1.2
tag is intended to provide a way to ensure that the upgraded application set remains fully compatible with other applications installed on the device.
Page 48 of 60
4.1.2
You can upgrade an application set either through the UI (refer to section 14.2.2) or through APIs (refer to section 14.2.3).
If you have the update package, you can just click on the Add software link in top left of page to upload the update package.
Page 49 of 60
4.1.2
Upload the update package to the device. This shows if the update is available to be applied.
Page 50 of 60
4.1.2
Add the package to the URL defined in the File element of the upgrade.xml file. Make the upgrade.xml file available for download in the URL defined in the UpgradeInfo element of the applicationSet.xml file.
Page 51 of 60
4.1.2
Copy only the customized parts of the old Makefile scripts (for both the application and application set projects) to the new files in the respective projects, observing the following changes: The Makefile for application sets has been completely rearranged to contain only the code that is specific for each application set. All common code and definitions were moved to the Makefile.in file: Removed "UPGRADE_TARGETS" definition Removed "PKG_LIST_FILE" and "PKG_LIST_FILE_FULL" definitions The "all" target now depends on "package-create" instead of "package" Removed all targets after "all" target, expect for ".PHONY" Moved the "include $(LLSDK_HOME)/Makefile.in" directive to be after the "all" target Replaced "package" with "package-create" in the ".PHONY" target definition
The Makefile for applications has been modified in specific points to remove the support for features that are no longer available: Removed variables for backup/rollback/remove scripts and all references to them Removed variable definition for "control" directory and all references to it Moved the "include $(LLSDK_HOME)/Makefile.in" directive to be after the "all" target Removed any o2 check_app ..." calls
Page 52 of 60
4.1.2
The "sdkapibld" target now depends on "app-create-dirs" Removed the "$(eval $(call CREATE_PACKAGE_TARGETS, <application id>, package))" call that existed before the "package" target Removed "deb_control" dependency from "package" target Replaced all "cp -rf" commands with "cp -rfp" Removed "install" target
With the constant evolution of the LifeLine REST APIs, existing APIs may be modified. Some of the possible changes include: new input parameters, changes to existing input parameters, changes to the return values, removal of existing input parameters and deprecated APIs. If you do not follow these changes, you may experience API calls to fail or unexpected values to be returned. It is important to check whether any of the LifeLine APIs used by your SDK application are affected. The complete list of affected APIs can be found in the Release Notes available as part of the SDK documentation.
Update the version of the CPipc and its header files in the application Makefile to 2.2. It is no longer necessary to add the upgrade parameter to the make call to build an upgrade package for your SDK application set. The upgrade.xml is always included by default now.
In addition to these basic steps, depending on the version of the LifeLine SDK from which your application or application set is being migrated, additional steps may be required, as described in the following sections.
Individually copy each attribute value from the old application.xml, <applicationSet_id>.xml and <applicationSet_id>_upgrade.xml files to the new files, observing the changes below. Simply copypasting the entire XML files on top of the new ones may invalidate the process. All the URLs and relative paths specified in the application.xml file must now be defined as relative to the applications www directory. The setup element should not be present in the application.xml file unless the application is actually added to the setup category. Applications can no longer have multiple executables defined in their application.xml files. Applications that still require more than one executable to be controlled by LifeLines Application Manager should be divided into two or more applications with one executable per application. The upgrade/name element of the <applicationSet_id>_upgrade.xml is no longer needed. New placeholders are added to the URLs specified in the <applicationSet_id>.xml and <applicationSet_id>_upgrade.xml files to facilitate the automatic generation of different URLs for each SDK target.
The backend functions that are registered to handle REST APIs exposed by the SDK application must now receive the incoming parameters in the form of a hash table, instead of the fixed-order list as before. All such functions must be updated according to the details in section 12.6.
Page 53 of 60
4.1.2
It is no longer necessary to keep the executable of an SDK application locked in an infinite loop to handle incoming IPC calls. This was usually done when the executable registered backend functions as handlers for REST APIs exposed by the SDK application. The executable of an SDK application is now automatically started by the Application Manager when it needs to handle an incoming IPC call. Refer to section 6.4 for details on the new interaction model between the Application Manager and the executables from SDK applications.
The Application Manager page no longer displays the running state of the SDK application sets, nor allows users to start or stop them. Since the real running state of an application might depend on other factors and the enable/disable operation might require more changes than simply stopping one specific executable file, SDK applications must display their running state and allow users to enable or disable the application through their own UI pages. Refer to section 13.3 for additional details.
The CPipc library and related header files are now versioned. This version number matches the version number of the LifeLine REST APIs. The names of the binary file of the CPipc library and the directory holding its related header files now carry the version number of the library. The Makefile of existing SDK applications must be updated to include this version number when linking the CPipc library and when including the directory of the related header files. Refer to section 12.1.2 for details.
The change above allows SDK applications to link with specific versions of the CPipc library and use it to make direct calls to LifeLine APIs. Refer to section 12.10 12.10 for details. The cpIpcStartListener function takes one input parameter, name, that must consist of the vendor name and the application id, in the form <vendor>_<app_id>. Refer to section 12.1.2 for details.
Add calls to cpIpcInit and cpIpcStartListener before using any of the functions in CPipc.h, as described in section 12.1.2.1. Remove any references to CP.h, Event.h, or any other header file that is no longer included in the LifeLine SDK. The available header files are located at: $LLSDK_HOME/<architecture>/usr/include/CP.
Remove any references to LifeLine functions that are not exposed in one of the header files included in the current version of the LifeLine SDK. The File/URL attribute must be replaced by the File/Url attribute, containing the URL of the remote directory that holds the TGZ installation package without the filename.
Page 54 of 60
4.1.2
17 Debugging Applications
Developers can debug SDK applications using the GDB debugger on the target device. Compile your SDK application with appropriate debug options for debugging the application.
19 Getting Help
The LenovoEMC LifeLine Developer community offers forums, blogs, and documentation for the LifeLine SDK. Refer to http://developer.lifelineapps.com.
Page 55 of 60
4.1.2
Page 56 of 60
4.1.2
Page 57 of 60
4.1.2
Page 58 of 60
4.1.2
Page 59 of 60
4.1.2
The page of each sample application contains an explanation of the features being demonstrated by it and instructions on how to use them.
Page 60 of 60
4.1.2