===========================================================================
|        MultiTech Custom App Development for Conduit AEP 1.3.x           |
===========================================================================

  As of 1.3.x, AEP supports installing and running user-created custom apps as 
  well as managing them from DeviceHQ. Node-RED can now be disabled to save 
  system resources if not being used.

  Supported languages:
    - C/C++
    - Python
    - Nodejs

  Custom applications must conform to the structure defined below and contain
  all required files in proper format.

  The new app-manager program on the Conduit is exclusively used to manage
  custom apps. All custom apps are installed, uninstalled, started,
  stopped, et cetera through app-manager.

  During development, custom apps can be installed directly on the Conduit
  without DeviceHQ by using "app-manager --command local". For production,
  custom app tarballs will be uploaded to DeviceHQ through the DeviceHQ web
  interface and installed on a Conduit by queuing an "Install App" action.


===========================
|  Application Structure  |
===========================

  application.tar/
    + provisioning/       (optional)
      - p_manifest.json   (optional)
    + config/             (optional)
    - Install             (required)
    - Start               (required)
    - manifest.json       (required)
    - status.json         (optional)

TARBALL ARCHIVE:

  The application archive should be a gzipped tar file with all required files.
  It can be named anything and doesn't have to match the app name in manifest.json.

MANIFEST.JSON:
  
  manifest.json is required and must contain the following keys: AppName, 
  AppVersion, AppDescription, and AppVersionNotes. These keys will be used
  for identifying the app from the Conduit and DeviceHQ UI's.

INSTALL SCRIPT:

  The Install script is used to install and uninstall apps. It must accept
  the following command line arguments: install, postinstall, and remove.

START SCRIPT:

  The Start script is used to stop, restart, and start the app. Apps will be
  automatically started on boot and stopped on shutdown. This script must
  accept the following command line arguments: start and stop.

PROVISIONING DIRECTORY:

  The provisioning/ directory is optional if no ipk dependencies need installed.
  If an app depends on libraries not installed by default on the Conduit, 
  they need to be included either in the app directory or packaged as ipk's
  in provisioning/. Additionally, ipk's must be listed in 
  provisioning/p_manifest.json. The Install script will use p_manifest.json
  to install the ipk dependencies on the Conduit's root file system. 
  These dependencies will be automatically reinstalled after a firmware upgrade
  and uninstalled while uninstalling the app.

CONFIG DIRECTORY:

  The config/ directory is optional but config files downloaded from DeviceHQ 
  will be installed here. app-manager will create the config/ directory during
  config install if it doesn't already exist.

STATUS.JSON:

  If status.json is present, it is used by app-manager to track application 
  status. If status.json contains the "pid" key, app-manager will do
  "kill -0 <pid>" on the pid to determine if the app is running or not.
  Custom apps can write a custom status string of 160 characters maximum to
  the "AppInfo" key in status.json. This field will be shown on the Conduit
  and DeviceHQ UI.


=================
|  DEVELOPMENT  |
=================

  Two bash scripts are provided for iterative local development.

  copy-to-conduit.sh takes a directory and ip address and simply
  copies the directory to /media/card/ on the Conduit. This can be used
  if you want to try manually running your app on the Conduit.

  install-to-conduit.sh takes a directory and ip address and does a full
  install. It tars up the app, copies it to /media/card/ on the Conduit,
  then uses app-manager to install the app locally. After install,
  you can see the app status on the Conduit's Apps UI page or via command
  line with this command:

    app-manager --command status

  You can also stop or start this app from the UI or by using these commands:

    app-manager --command start --appid LOCAL
    app-manager --command restart --appid LOCAL
    app-manager --command stop --appid LOCAL

  NOTE: You must uninstall this installed app before installing the
  same app through DHQ with this command:

    app-manager --command remove --appid LOCAL


==================================
|  PRODUCTION USE WITH DEVICEHQ  |
==================================

  Upload the application tarball to DeviceHQ from the Developer page.

  Schedule this app to be installed to one or more Conduit's from the 
  Devices page.

  After installed, the custom app and its status should show in the device
  details when clicking on a single device from the Devices page.

  Custom apps can then be uninstalled from DeviceHQ by scheduling an
  "Uninstall App" action.

  Config files for a custom app can be uploaded to DeviceHQ from the
  Developer page by clicking on a custom app and then clicking on the
  Configurations tab. After it's uploaded, an app config can be installed
  on a Conduit in the config/ directory by scheduling an "Install App Config"
  action. After app-manager downloads the config file and places it in
  config/, it will restart the application.


================
|  CONDUIT UI  |
================

  The revamped Apps page now shows both installed Node-RED and custom apps.
  The name, version, status, and info fields are shown for custom apps. The
  description can be seen by hovering over the custom app name. The version
  notes can be seen by hovering over the version.

  Custom apps can be stopped, started, and uninstalled from the UI.

