Below is a sample plugin to help you understand Allxon Octo framework.
The plugin infrastructure is based on Allxon Agent. To run the pre-build executable, install Allxon Agent first.
Go to the release page, then download your platform archive.
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.
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.jsonis paired with one plugin program. Different platforms or CPU architectures require different plugin credentials. Make sure you use the suitableplugin_credential.json.
sudo docker build .- CMake 3.23 - installation link
- Allxon Octo SDK
- OpenSSL
The Allxon Octo SDK library is auto fetched when you configure cmake.
Install OpenSSL in Linux Debian.
apt-get update && apt-get install libssl-devFollow the installation instructions on the OpenSSL official site.
# 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@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_windowsA 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 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# Deploy through cmake, then you can get your plugin package under build directory
cmake --build build --config <release|debug> --target packageAfter building the plugin package, use the following commands to install and test it on your device.
sudo allxon-cli plugin --app-guid <APP_GUID> install --package <PLUGIN_PACKAGE>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:
sudo allxon-cli plugin --app-guid <APP_GUID> uninstallallxon-cli.exe plugin --app-guid <APP_GUID> uninstallOnce configured, You can use the following predefined marcos:
PLUGIN_NAMEPLUGIN_APP_GUIDPLUGIN_ACCESS_KEYPLUGIN_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;
}