Skip to content

A sample plugin to help you understand Allxon Octo framework.

License

Notifications You must be signed in to change notification settings

allxon/plugIN-hello

Repository files navigation

Hello Plugin

Below is a sample plugin to help you understand Allxon Octo framework.

Run Pre-Build Executable

Install Allxon Agent

The plugin infrastructure is based on Allxon Agent. To run the pre-build executable, install Allxon Agent first.

Download the Plugin Package

Go to the release page, then download your platform archive.

Extract and Run

After your archive is downloaded, extract and run the archive.

cd <EXTRACT_FOLDER_PATH>/<APP_GUID>
./plugin-hello $(pwd)

or Windows cmd.

cd <EXTRACT_FOLDER_PATH>\<APP_GUID>
plugin-hello.exe %cd%

NOTE: The plugin executable only tested on Ubuntu 18.04 and Windows 10. If you want to run the plugin on other platforms, please build from source.

Build from Source

Obtain Plugin Credential

You need to acquire a Plugin Credential, which represents your plugin identity. To do so, contact us to obtain plugin_credential.json, which includes a set of APP_GUID and ACCESS_KEY.

WARNING: Each plugin_credential.json is paired with one plugin program. Different platforms or CPU architectures require different plugin credentials. Make sure you use the suitable plugin_credential.json.

Docker build

sudo docker build .

Install CMake

Dependency

The Allxon Octo SDK library is auto fetched when you configure cmake.

Linux Debian

Install OpenSSL in Linux Debian.

apt-get update && apt-get install libssl-dev

Other Linux Distribution & Windows

Follow the installation instructions on the OpenSSL official site.

Build and Run

Linux

# Configuration Stage
cmake -S . -B build -DCMAKE_BUILD_TYPE=<Debug|Release> -DPLUGIN_KEY=plugin_credential.json 

# Specify octo sdk version
cmake -S . -B build -DCMAKE_BUILD_TYPE=<Debug|Release> -DPLUGIN_KEY=plugin_credential.json -DOCTO_SDK_VERSION=X.X.X

# Build Stage
cmake --build build

# Run after build
# You can run plugin-hello directly under the build/ folder, and pass resource_dir_linux through argument
build/plugin-hello resource_dir_linux

Windows

@REM Configuration Stage
cmake -G "Visual Studio 16 2019" -A x64 -S . -B "build" -DPLUGIN_KEY=plugin_credential.json

@REM Specify octo sdk version
cmake -G "Visual Studio 16 2019" -A x64 -S . -B "build" -DOCTO_SDK_VERSION=X.X.X

@REM Build Stage
cmake --build build --config Release

@REM Run after build
@REM You can run plugin-hello directly under the build\ folder, and pass resource_dir_windows through argument
build\Release\plugin-hello.exe resource_dir_windows

How to Deploy and Install

A Plugin Package is an archived plugin which is workable with Allxon Plugin Center. (Contact us for detailed listing process)

The file naming convention of a plugin package is plugin-hello-[version]-linux-[arch].tar.gz (Linux) or plugin-hello-[version]-win-[arch].zip (Windows).

Deploy Plugin Package

Linux

# Deploy through docker, then you can get your plugin package under OUTPUT_DIRECTORY 
sudo docker build -o <OUTPUT_DIRECTORY> .

# Specify octo sdk version
sudo docker build -o <OUTPUT_DIRECTORY> --build-arg CMAKE_ARGS="-DOCTO_SDK_VERSION=X.X.X" .
# Deploy through cmake, then you can get your plugin package under build directory
cmake --build build --target package

Windows

# Deploy through cmake, then you can get your plugin package under build directory
cmake --build build --config <release|debug> --target package

Test Plugin Installation through allxon-cli

After building the plugin package, use the following commands to install and test it on your device.

Linux

sudo allxon-cli plugin --app-guid <APP_GUID> install --package <PLUGIN_PACKAGE>

Windows

allxon-cli.exe plugin --app-guid <APP_GUID> install --package <PLUGIN_PACKAGE>

Once installed, the plugin starts automatically.

If you want to uninstall the plugin, use the following commands:

Linux

sudo allxon-cli plugin --app-guid <APP_GUID> uninstall

Windows

allxon-cli.exe plugin --app-guid <APP_GUID> uninstall

Getting Started

Once configured, You can use the following predefined marcos:

  • PLUGIN_NAME
  • PLUGIN_APP_GUID
  • PLUGIN_ACCESS_KEY
  • PLUGIN_VERSION
#include <iostream>
#include "octo/octo.h"
#include "websocket_client.h"

using namespace Allxon;

std::string Util::plugin_install_dir = "";

int main(int argc, char **argv)
{
    if (argc == 1)
    {
        std::cout << "Please provide a plugin install directory." << std::endl;
        return 1;
    }
    else if (argc > 2)
    {
        std::cout << "Wrong arguments. Usage: device_plugin [plugin install directory]" << std::endl;
        return 1;
    }
    Util::plugin_install_dir = std::string(argv[1]);
    WebSocketClient web_client(std::make_shared<Octo>(
        PLUGIN_NAME, PLUGIN_APP_GUID,
        PLUGIN_ACCESS_KEY, PLUGIN_VERSION,
        Util::getJsonFromFile(Util::plugin_install_dir + "/plugin_update_template.json")));
    web_client.run();
    return 0;
}

About

A sample plugin to help you understand Allxon Octo framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •